From: oiffrig <Ba...@us...> - 2010-05-19 21:22:48
|
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 01b2cdeb8eb11b676481e41d063dffaa328d9a39 (commit) from 8fd8ec3e9dcd92b88815208378605cc61d4125bf (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 01b2cdeb8eb11b676481e41d063dffaa328d9a39 Author: Olivier Iffrig <if...@cr...> Date: Wed May 19 23:20:47 2010 +0200 Made ax12Configure a bit safer ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c index b985cfe..dd17855 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.c @@ -134,19 +134,22 @@ void ax12SendPacket(uint8_t id, uint8_t instruction, uint8_t len, uint8_t *param chSysUnlock(); } -void ax12Configure(uint8_t id) { +void ax12Configure(uint8_t old_id, uint8_t new_id) { uint8_t paramsDelay[] = {P_RETURN_DELAY_TIME, 0x0A}; - uint8_t paramsID[] = {P_ID, id}; + uint8_t paramsID[] = {P_ID, new_id}; + // UNSAFE !! + /* // Reset default settings ax12SendPacket(ID_BROADCAST, INST_RESET, 0, NULL); chThdSleepMilliseconds(1); // Set response delay at maximum ax12SendPacket(ID_BROADCAST, INST_WRITE, sizeof(paramsDelay), paramsDelay); chThdSleepMilliseconds(1); + */ // Set ID - ax12SendPacket(ID_BROADCAST, INST_WRITE, sizeof(paramsID), paramsID); + ax12SendPacket(old_id, INST_WRITE, sizeof(paramsID), paramsID); chThdSleepMilliseconds(1); } diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h index 1bc22a9..a685bcc 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ax12.h @@ -126,7 +126,7 @@ void ax12Init(void); void ax12SendPacket(uint8_t id, uint8_t instruction, uint8_t len, uint8_t *params); -void ax12Configure(uint8_t id); +void ax12Configure(uint8_t old_id, uint8_t new_id); void ax12Goto(uint8_t id, uint16_t position, uint16_t speed, uint8_t mode); void ax12Action(uint8_t id); void ax12Ping(uint8_t id); diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c index d798cab..abf1662 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c @@ -200,7 +200,7 @@ void liftHandler(BaseChannel *chp, int argc, char* argv[]) { void ax12Handler(BaseChannel *chp, int argc, char* argv[]) { - uint8_t id; + uint8_t id, new_id; uint16_t pos, spd; if (argc < 2) { @@ -211,11 +211,12 @@ void ax12Handler(BaseChannel *chp, int argc, char* argv[]) { id = atoi_h(argv[1]); if(strcmp(argv[0], "config") == 0) { - if (argc != 2) { - shellPrintLine(chp, "Usage : ax12 config id"); + if (argc != 3) { + shellPrintLine(chp, "Usage : ax12 config old_id new_id"); return; } - ax12Configure(id); + new_id = atoi_h(argv[2]); + ax12Configure(id, new_id); } else if(strcmp(argv[0], "goto") == 0) { if (argc != 4) { hooks/post-receive -- krobot |