| 162 | } |
| 163 | |
| 164 | INT8U Can232::parseAndRunCommand() { |
| 165 | INT8U ret = LW232_OK; |
| 166 | INT8U idx = 0; |
| 167 | INT8U err = 0; |
| 168 | |
| 169 | lw232LastErr = LW232_OK; |
| 170 | |
| 171 | // __debug_buf("RX:", (char*)lw232Message, strlen((char*)lw232Message)); |
| 172 | |
| 173 | switch (lw232Message[0]) { |
| 174 | case LW232_CMD_SETUP: |
| 175 | // Sn[CR] Setup with standard CAN bit-rates where n is 0-9. |
| 176 | if (lw232CanChannelMode == LW232_STATUS_CAN_CLOSED) { |
| 177 | idx = HexHelper::parseNibbleWithLimit(lw232Message[1], LW232_CAN_BAUD_NUM); |
| 178 | lw232CanSpeedSelection = lw232CanBaudRates[idx]; |
| 179 | } |
| 180 | else { |
| 181 | ret = LW232_ERR; |
| 182 | } |
| 183 | break; |
| 184 | case LW232_CMD_SETUP_BTR: |
| 185 | // sxxyy[CR] Setup with BTR0/BTR1 CAN bit-rates where xx and yy is a hex value. |
| 186 | ret = LW232_ERR; break; |
| 187 | case LW232_CMD_OPEN: |
| 188 | // O[CR] Open the CAN channel in normal mode (sending & receiving). |
| 189 | if (lw232CanChannelMode == LW232_STATUS_CAN_CLOSED) { |
| 190 | ret = openCanBus(); |
| 191 | if (ret == LW232_OK) { |
| 192 | lw232CanChannelMode = LW232_STATUS_CAN_OPEN_NORMAL; |
| 193 | } |
| 194 | } |
| 195 | else { |
| 196 | ret = LW232_ERR; |
| 197 | } |
| 198 | break; |
| 199 | case LW232_CMD_LISTEN: |
| 200 | // L[CR] Open the CAN channel in listen only mode (receiving). |
| 201 | if (lw232CanChannelMode == LW232_STATUS_CAN_CLOSED) { |
| 202 | ret = openCanBus(); |
| 203 | if (ret == LW232_OK) { |
| 204 | lw232CanChannelMode = LW232_STATUS_CAN_OPEN_LISTEN; |
| 205 | } |
| 206 | } |
| 207 | else { |
| 208 | ret = LW232_ERR; |
| 209 | } |
| 210 | break; |
| 211 | case LW232_CMD_CLOSE: |
| 212 | // C[CR] Close the CAN channel. |
| 213 | if (lw232CanChannelMode != LW232_STATUS_CAN_CLOSED) { |
| 214 | lw232CanChannelMode = LW232_STATUS_CAN_CLOSED; |
| 215 | } |
| 216 | else { |
| 217 | ret = LW232_ERR; |
| 218 | } |
| 219 | break; |
| 220 | case LW232_CMD_TX11: |
| 221 | // tiiildd...[CR] Transmit a standard (11bit) CAN frame. |
nothing calls this directly
no test coverage detected