Commit 39913733 authored by Pavel Pisa's avatar Pavel Pisa

driver: add option to define CAN ID for user-space test transmit ion.

Signed-off-by: Pavel Pisa's avatarPavel Pisa <pisa@cmp.felk.cvut.cz>
parent b5849857
Pipeline #8632 failed with stage
...@@ -201,6 +201,7 @@ int main(int argc, char *argv[]) ...@@ -201,6 +201,7 @@ int main(int argc, char *argv[])
int gap = 1000; int gap = 1000;
int bitrate = 1000000; int bitrate = 1000000;
int dbitrate = 0; int dbitrate = 0;
int tx_can_id = 0x1ff;
bool do_periodic_transmit = false; bool do_periodic_transmit = false;
bool transmit_fdf = false; bool transmit_fdf = false;
bool loopback_mode = false; bool loopback_mode = false;
...@@ -211,7 +212,7 @@ int main(int argc, char *argv[]) ...@@ -211,7 +212,7 @@ int main(int argc, char *argv[])
int c; int c;
char *e; char *e;
const char *progname = argv[0]; const char *progname = argv[0];
while ((c = getopt(argc, argv, "i:a:g:b:B:fltThpr")) != -1) { while ((c = getopt(argc, argv, "i:a:g:b:B:I:fltThpr")) != -1) {
switch (c) { switch (c) {
case 'i': case 'i':
ifc = strtoul(optarg, &e, 0); ifc = strtoul(optarg, &e, 0);
...@@ -243,6 +244,12 @@ int main(int argc, char *argv[]) ...@@ -243,6 +244,12 @@ int main(int argc, char *argv[])
err(1, "-B expects a number"); err(1, "-B expects a number");
break; break;
case 'I':
tx_can_id = strtoul(optarg, &e, 0);
if (*e != '\0')
err(1, "-I expects a number");
break;
case 'l': loopback_mode = true; break; case 'l': loopback_mode = true; break;
case 't': do_transmit = true; break; case 't': do_transmit = true; break;
case 'T': do_periodic_transmit = true; break; case 'T': do_periodic_transmit = true; break;
...@@ -402,7 +409,7 @@ int main(int argc, char *argv[]) ...@@ -402,7 +409,7 @@ int main(int argc, char *argv[])
if (do_transmit) { if (do_transmit) {
struct canfd_frame txf; struct canfd_frame txf;
txf.can_id = 0x1FF; txf.can_id = tx_can_id;
txf.flags = 0; txf.flags = 0;
//u8 d[] = {0xde, 0xad, 0xbe, 0xef}; //u8 d[] = {0xde, 0xad, 0xbe, 0xef};
u8 d[] = {0xDE, 0xAD, 0xBE, 0xEF}; u8 d[] = {0xDE, 0xAD, 0xBE, 0xEF};
...@@ -454,13 +461,12 @@ int main(int argc, char *argv[]) ...@@ -454,13 +461,12 @@ int main(int argc, char *argv[])
if (do_periodic_transmit && (loop_cycle & 1)) { if (do_periodic_transmit && (loop_cycle & 1)) {
struct canfd_frame txf; struct canfd_frame txf;
memset(&txf, 0, sizeof(txf)); memset(&txf, 0, sizeof(txf));
txf.can_id = 0x1FF; txf.can_id = tx_can_id;
txf.flags = 0; txf.flags = 0;
if (transmit_fdf) { if (transmit_fdf) {
txf.flags |= CANFD_BRS; txf.flags |= CANFD_BRS;
u8 dfd[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee}; u8 dfd[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee};
txf.can_id = 0x123;
memcpy(txf.data, dfd, sizeof(dfd)); memcpy(txf.data, dfd, sizeof(dfd));
txf.len = sizeof(dfd); txf.len = sizeof(dfd);
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment