1 2 3 4 | title Fedora Core (2.6.15hdaps) root (hd0,0) kernel /vmlinuz-2.6.15hdaps ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /hdapsInitrd.img |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /* * panicShake - reboot the machine if shaken */ extern void panicShake(void) { int ret, x, y; // return value and x,y from hdaps int int baseX = -5000; // off scale default values int baseY = -5000; int totalDev = 0; // running total of deviations from rest (shaking total) int devThreshold = 4000; // larger threshold for more shaking int dimShiftX = 150; // in case your users shake more in a certain dimension int dimShiftY = 150; while(1) { ret = hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y); if (!ret) { if( x != 0 && y != 0 ) { // if its a successful read and not a zero read if( baseX == -5000 ) { baseX = x; baseY = y; } if( abs(baseX - x) > dimShiftX || abs(baseY - y) > dimShiftY ) { totalDev += abs(baseX - x); totalDev += abs(baseY - y); } if( totalDev > devThreshold ) { printk(KERN_EMERG "ok, ok! you're shaking my substrate - restarting"); emergency_restart(); } }//if not a zero value }//if successful read of hdaps data }//infinite while }//panicShake |
1 2 3 4 5 6 7 | int ret, x, y; // return value and x,y from hdaps int baseX = -5000; // off scale default values int baseY = -5000; int totalDev = 0; // running total of deviations from rest (shaking total) int devThreshold = 4000; // larger threshold for more shaking int dimShiftX = 150; // in case your users shake more in a certain dimension int dimShiftY = 150; |
1 2 3 4 5 6 7 8 9 10 11 12 13 | while(1) { ret = hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y); if (!ret) { if( x != 0 && y != 0 ) { // if its a successful read and not a zero read if( baseX == -5000 ) { baseX = x; baseY = y; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | if( abs(baseX - x) > dimShiftX || abs(baseY - y) > dimShiftY ) { totalDev += abs(baseX - x); totalDev += abs(baseY - y); baseX = x; baseY = y; } if( totalDev > devThreshold ) { printk(KERN_EMERG "ok, ok! you're shaking my substrate - restarting"); emergency_restart(); } }//if not a zero value }//if successful read of hdaps data }//infinite while |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |