From: oiffrig <Ba...@us...> - 2010-05-18 22:41:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via d542edc38e91ec78cb02cff00a424482e0ed4431 (commit) from cbac0a188371704814e4d9a0e96e857c412900b2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d542edc38e91ec78cb02cff00a424482e0ed4431 Author: Olivier Iffrig <if...@cr...> Date: Wed May 19 00:39:45 2010 +0200 Handmade atoi, the built-in one crashes... ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c index e412837..97fe585 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c @@ -10,6 +10,32 @@ Thread *cdtp; /* + * Handmade atoi, because the one from standard lib does not work + */ +int32_t atoi_h(char *str) { + int32_t res = 0; + uint8_t neg = 0; + + while(isspace((int)*str)) + str++; + + switch(*str) { + case '-': + neg = 1; + case '+': + str++; + break; + } + + for(; isdigit((int)*str); str++) { + res *= 10; + res += *str - '0'; + } + + return neg? -res : res; +} + +/* * Thread to print text into the monitor in a thread safe way */ static msg_t consoleThread(void* arg) { @@ -141,12 +167,12 @@ void moveHandler(BaseChannel *chp, int argc, char* argv[]) { shellPrintLine(chp, "Usage : move ptX ptY vX vY omega t"); return; } - ptX = atoi(argv[0]); - ptY = atoi(argv[1]); - vX = atoi(argv[2]); - vY = atoi(argv[3]); - omega = atoi(argv[4]); - t = atoi(argv[5]); + ptX = atoi_h(argv[0]); + ptY = atoi_h(argv[1]); + vX = atoi_h(argv[2]); + vY = atoi_h(argv[3]); + omega = atoi_h(argv[4]); + t = atoi_h(argv[5]); canSetScrew(ptX, ptY, vX, vY, omega); chThdSleepMilliseconds(t); @@ -170,7 +196,7 @@ void liftHandler(BaseChannel *chp, int argc, char* argv[]) { shellPrintLine(chp, "Usage : lift (up|down|move h)"); return; } - h = atoi(argv[1]); + h = atoi_h(argv[1]); } else { shellPrintLine(chp, "Usage : lift (up|down|move h)"); hooks/post-receive -- krobot |