uint32_t can_src, can_dst;
canBASE_t *canBases[3] = {canREG1, canREG2, canREG3};
uint32_t canMailBoxes[3] = {canMESSAGE_BOX1, canMESSAGE_BOX2, canMESSAGE_BOX3};
- char* token = NULL;
uint32_t txTimeOutCnt = 0;
uint32_t rxTimeOutCnt = 0;
uint32_t messagesTransmitted = 0;
uint32_t i;
uint8_t tx_data[8] = {'T', 'E', 'S', 'T', ' ', 'C', 'A', 'N'};
uint8_t rx_data[8] = {0, 0, 0, 0, 0, 0, 0, 0 };
+ char *p=param[1];
+ char spareParams;
dmmREG->PC4 = (1<<(13)); // set CAN_NSTB
dmmREG->PC4 = (1<<(15)); // set CAN_EN
vTaskDelay(50/portTICK_RATE_MS);
- // Get can ID 1
- if ((token = strtok(param[1], " ")) == NULL) {
- rpp_sci_printf("ERROR: Parameter 1 expected.\n");
- return 1;
- }
- if (EOF == sscanf(token, "%d", &can_src)){
- rpp_sci_printf("ERROR: unsigned number expected as param 1!\n");
- return 1;
- }
- // Get can ID 2
- if ((token = strtok(NULL, " ")) == NULL) {
- rpp_sci_printf("ERROR: Parameter 2 expected.\n");
- return 1;
- }
- if (EOF == sscanf(token, "%d", &can_dst)){
- rpp_sci_printf("ERROR: unsigned number expected as param 2!\n");
- return 1;
- }
- if ((token = strtok(NULL, " ")) != NULL) {
- rpp_sci_printf("ERROR: More than 2 parameters detected!\n");
- return 1;
+ if (sscanf(p, "%d %d %1s", &can_src, &can_dst, &spareParams) != 2) {
+ return -CMDERR_BADPAR;
}
+
if (can_src == can_dst) {
rpp_sci_printf("ERROR: Destination equals source!\n");
return 1;
"\n"
"=== Example ===\n"
"\n"
- " --> cantest 1 2\n"
+ " --> cantest1 2\n"
" Testing CAN loopback\n"
" Messages transmitted: 100/100\n"
" Messages received: 100/100\n"