36#include <socan_util.h>
48typedef enum { T_CHECK=2, T_REMOTE=4,
105static void test_bitrate(
int port)
108 unsigned int bitrate;
113 printf(
"sotest.c line %d: socan_port_bitrate returned an error: %d (%s)\n",
115 printf(
"test-abort!\n");
118 printf(
"bitrate of port %d is %u\n", port, bitrate);
122static void test_simple_rw(
int object1,
int port1,
int object2,
int port2,
123 int w_timeout,
int r_timeout,
128 unsigned char wbuf[8];
129 unsigned char rbuf[8];
133 printf(
"opening driver :\n");
138 printf(
"opening of driver failed\n");
142 printf(
"8 bytes will be written, content of these 8 bytes:\n");
143 printf(
"1 2 3 4 5 6 7 8\n");
145 printf(
"set write-mode for object %d, port %d ...",object1, port1);
146 printf(
"(timeout %d)\n", w_timeout);
151 printf(
"sotest.c line %d: socan_add_obj returned an error: %d (%s)\n",
153 printf(
"test-abort!\n");
160 printf(
"set read-mode for object %d, port %d ...",object2, port2);
161 printf(
"(timeout %d)\n", r_timeout);
166 printf(
"sotest.c line %d: socan_add_obj returned an error: %d (%s)\n",
168 printf(
"test-abort!\n");
178 if (flag & T_TIMESTAMP)
180 printf(
"time now : %lu\n", timestamp_us());
183 printf(
"now writing the data...");
187 printf(
"sotest.c line %d: socan_write returned %d (%s)\n",
191 if (flag & T_TIMESTAMP)
196 printf(
"sotest.c line %d: socan_obj_ts returned %d (%s)\n",
199 printf(
"timestamp: %lu\n", ts);
202 printf(
"now reading the data...");
206 printf(
"sotest.c line %d: socan_read returned %d (%s)\n",
210 if (flag & T_TIMESTAMP)
215 printf(
"sotest.c line %d: socan_obj_ts returned %d (%s)\n",
218 printf(
"timestamp: %lu\n", ts);
221 printf(
"message-content:\n");
222 nice_dump(rbuf, 8, 0);
224 printf(
"closing driver...\n");
227 printf(
"closing failed !\n");
233static void test_write(
int object,
int port,
unsigned int timeout,
234 unsigned long inhibit_tm,
241 int countsize,
int countstart,
245 unsigned long counter;
246 char cbuf[8]= {0, 0, 0, 0, 0, 0, 0, 0};
248 long loopdelay_long= (loopdelay==0) ? 0 : (long)(loopdelay*1000+0.5);
254 bool timed= (write_cmd==CMD_WRITE_INHIBIT);
255 bool busy_wait= (write_cmd==CMD_WRITE_LATER_W);
256 bool write_rtr_frame= (write_cmd==CMD_WRITE_RTR);
257 unsigned long timeval;
259 const char *func_name;
262 int loops_got= loops;
263 unsigned long start_time_ms, end_time_ms;
267 case CMD_WRITE_INHIBIT:
268 func_name=
"socan_write_inhibit";
270 case CMD_WRITE_LATER:
271 case CMD_WRITE_LATER_W:
273 func_name=
"socan_writelater";
276 func_name=
"socan_write";
279 printf(
"internal error line %d\n", __LINE__);
287 printf(
"sleeping %f seconds...\n", sleep);
288 mldelay((
long)(sleep*1000+0.5));
290 printf(
"opening driver :\n");
294 printf(
"opening of driver failed\n");
298 printf(
"defining write-object...\n");
308 rc=
socan_add_obj(hdl, port,
object, countsize, timeout, objtype);
311 printf(
"sotest.c line %d: socan_add_obj returned an error: %d (%s)\n",
313 printf(
"test-abort!\n");
324 printf(
"sotest.c line %d: socan_set_inhibit returned "
326 printf(
"test-abort!\n");
338 eval_quietlevel(quietlevel, &scale, &ch, &l);
340 start_time_ms= timestamp_ms();
341 for(; loops>0; loops--)
344 mldelay(loopdelay_long);
345 if (flag & T_CONSISTENCE)
347 unsigned char b= (
unsigned char) counter;
348 for(i=0; i<countsize; cbuf[i++]= b);
354 memcpy(cbuf, &counter, countsize);
357 {
if (quietlevel > 0)
359 { l= scale; putchar(ch); fflush(stdout); };
362 {
if (flag & T_CONSISTENCE)
363 printf(
"consistency test with byte %lu\n", counter & 0xFF);
365 { printf(
"writing %lu, %d bytes on %d\n",
366 counter, countsize,
object);
372 case CMD_WRITE_INHIBIT:
376 case CMD_WRITE_LATER:
377 case CMD_WRITE_LATER_W:
404 printf(
"sotest.c line %d: %s returned an error: %d (%s)\n",
408 printf(
"%s return code: %d (%s)\n", func_name,
413 end_time_ms= timestamp_ms();
419 double dt= (end_time_ms-start_time_ms)/1000.0;
420 double wait_rate= ((double)waitcount) / loops_got;
421 printf(
"dt: %f loops_got: %d\n",dt, loops_got);
422 printf(
"statistic:\n");
423 printf(
"sent: %d\n", loops_got);
424 printf(
"run-time: %.2f s\n", dt);
425 printf(
"objects / s : %.1f\n", loops_got/dt);
426 printf(
"ms / object : %.3f\n", 1000*dt/loops_got);
427 printf(
"wait-rate: %.3f %%\n", wait_rate*100);
428 printf(
"errors: %d\n", errcount);
433 printf(
"sleeping %f seconds...\n", leave);
434 mldelay((
long)(leave*1000+0.5));
437 printf(
"\nclosing driver...\n");
440 printf(
"closing failed !\n");
445static void test_read(
int object,
int port,
unsigned int timeout,
451 int quietlevel,
bool readnow,
452 int countsize,
int flag)
456 long loopdelay_long= (loopdelay==0) ? 0 : (long)(loopdelay*1000+0.5);
460 unsigned long c,count= 0;
462 char cbuf[8]= {0, 0, 0, 0, 0, 0, 0, 0};
465 int loops_got= loops;
467 unsigned long start_time_ms, end_time_ms;
470 if (countsize>=
sizeof(
int))
473 mask= 0xFFFFFFFF >> ((
sizeof(int)-countsize)*8);
476 printf(
"sleeping %f seconds...\n", sleep);
477 mldelay((
long)(sleep*1000+0.5));
479 printf(
"opening driver :\n");
483 printf(
"opening of driver failed\n");
487 printf(
"defining read-object...\n");
492 rc=
socan_add_obj(hdl, port,
object, countsize, timeout, objtype);
495 printf(
"sotest.c line %d: socan_add_obj returned an error: %d (%s)\n",
497 printf(
"test-abort!\n");
504 eval_quietlevel(quietlevel, &scale, &ch, &l);
506 for(; loops>0; loops--)
509 mldelay(loopdelay_long);
516 start_time_ms= timestamp_ms();
522 { l= scale; putchar(ch); fflush(stdout); };
525 { printf(
"received data:\n");
526 nice_dump(cbuf, countsize, 0);
533 if (!(flag & T_IGNORE_OLD))
534 printf(
"\nread return-code: %d (%s)\n",
548 printf(
"\nread return-code: %d (%s)\n",
553 printf(
"\nread error-code: %d (%s)\n",
560 if (flag & T_CONSISTENCE)
563 for (i=1; i<countsize; i++)
566 printf(
"INCONSISTENT DATA!\n");
567 printf(
"received data:\n");
568 nice_dump(cbuf, countsize, 0);
575 memcpy(&c, cbuf, countsize);
578 if ((c>count) || (countsize>1))
581 printf(
"[%lx,%lx]",c,count);
583 printf(
"%lu messages missed, got:%lu expected:%lu\n",
587 printf(
"messages repeated, got:%lu, expected:%lu\n",
596 end_time_ms= timestamp_ms();
600 loss_rate= ((double)lostcount) / loops_got;
603 double dt= (end_time_ms-start_time_ms)/1000.0;
604 printf(
"statistic:\n");
605 printf(
"received: %d\n", loops_got);
606 printf(
"run-time: %.1f s\n", dt);
607 printf(
"objects / s : %.1f\n", loops_got/dt);
608 printf(
"ms / object : %.2f\n", 1000*dt/loops_got);
611 printf(
"lost: %d\n", lostcount);
612 printf(
"loss-rate: %.4f\n", loss_rate);
616 if (loss_rate <= maxlossrate)
617 printf(
"loss-rate <= %.4f\n", maxlossrate);
620 printf(
"lost: %d\n", lostcount);
621 printf(
"loss-rate %.4f > %.4f\n",
622 loss_rate, maxlossrate);
625 printf(
"errors: %d\n", errcount);
628 if ((loss_rate > maxlossrate) && (maxlossrate>=0))
629 printf(
"loss-rate %.4f > %.4f\n",
630 loss_rate, maxlossrate);
634 printf(
"sleeping %f seconds...\n", leave);
635 mldelay((
long)(leave*1000+0.5));
638 printf(
"closing driver...\n");
641 printf(
"closing failed !\n");
646static void test_queue_read(
int port_,
unsigned int timeout,
int *ids,
int id_no,
653 int countsize,
int flag)
657 char cbuf[8]= {0, 0, 0, 0, 0, 0, 0, 0};
667 unsigned long *count= NULL;
668 long loopdelay_long= (loopdelay==0) ? 0 : (long)(loopdelay*1000+0.5);
669 int *receivecount=NULL;
673 unsigned long start_time_ms, end_time_ms;
679 printf(
"wrong id_no: %d\n", id_no);
682 count= calloc(id_no,
sizeof(
unsigned long));
683 receivecount= calloc(id_no,
sizeof(
unsigned long));
684 lostcount= calloc(id_no,
sizeof(
unsigned long));
685 errcount= calloc(id_no,
sizeof(
unsigned long));
687 if (countsize>=
sizeof(
int))
690 mask= 0xFFFFFFFF >> ((
sizeof(int)-countsize)*8);
694 printf(
"sleeping %f seconds...\n", sleep);
695 mldelay((
long)(sleep*1000+0.5));
698 printf(
"opening driver :\n");
702 printf(
"opening of driver failed\n");
706 printf(
"defining read-objects...\n");
708 for(i=0; i<id_no; i++)
714 printf(
"sotest.c line %d: socan_add_obj returned an error: %d (%s)\n",
716 printf(
"test-abort!\n");
723 printf(
"sotest.c line %d: socan_use_queue returned "
724 "an error: %d (%s)\n",
726 printf(
"test-abort!\n");
733 printf(
"sotest.c line %d: socan_new_user_area returned "
734 "an error: %d (%s)\n",
736 printf(
"test-abort!\n");
744 eval_quietlevel(quietlevel, &scale, &ch, &l);
746 start_time_ms= timestamp_ms();
747 for(; loops>0; loops--)
750 mldelay(loopdelay_long);
754 start_time_ms= timestamp_ms();
759 printf(
"sotest.c line %d: socan_user_area returned "
760 "an error: %d (%s)\n",
762 printf(
"test-abort!\n");
768 receivecount[*iptr]++;
775 { l= scale; putchar(ch); fflush(stdout); };
779 printf(
"received on %d: data:\n", cob);
780 nice_dump(cbuf, countsize, 0);
797 printf(
"\nread return-code: %d (%s)\n",
802 printf(
"\nread error-code: %d (%s)\n",
810 if (flag & T_CONSISTENCE)
813 for (i=1; i<countsize; i++)
816 printf(
"INCONSISTENT DATA!\n");
817 printf(
"received data:\n");
818 nice_dump(cbuf, countsize, 0);
825 memcpy(&c, cbuf, countsize);
826 if (c != count[*iptr])
828 if ((c>count[*iptr]) || (countsize>1))
831 printf(
"[%d:%lx,%lx]",cob,c,count[*iptr]);
833 printf(
"cob %d: %lu messages missed, "
834 "got:%lu expected:%lu\n",
835 cob, c-count[*iptr], c, count[*iptr]);
838 printf(
"cob %d: messages repeated, "
839 "got:%lu, expected:%lu\n",
840 cob, c, count[*iptr]);
849 end_time_ms= timestamp_ms();
854 double dt= (end_time_ms-start_time_ms)/1000.0;
855 for(i=0; i<id_no; i++)
859 loss_rate= ((double)lostcount[i]) / receivecount[i];
860 printf(
"\nstatistic cob %d:\n", ids[i]);
861 printf(
"received: %d\n", receivecount[i]);
862 printf(
"run-time: %.1f s\n", dt);
863 printf(
"objects / s : %.1f\n", receivecount[i]/dt);
864 printf(
"ms / object : %.2f\n", 1000*dt/receivecount[i]);
867 printf(
"lost: %d\n", lostcount[i]);
868 printf(
"loss-rate: %.4f\n", loss_rate);
872 if (loss_rate <= maxlossrate)
873 printf(
"loss-rate <= %.4f\n", maxlossrate);
876 printf(
"lost: %d\n", lostcount[i]);
877 printf(
"loss-rate %.4f > %.4f\n",
878 loss_rate, maxlossrate);
881 printf(
"errors: %d\n", errcount[i]);
884 if ((loss_rate > maxlossrate) && (maxlossrate>=0))
885 printf(
"loss-rate %.4f > %.4f\n",
886 loss_rate, maxlossrate);
895 printf(
"sleeping %f seconds...\n", leave);
896 mldelay((
long)(leave*1000+0.5));
899 printf(
"\nclosing driver...\n");
902 printf(
"closing failed !\n");
913 printf(
" **** sotest %s ****\n", VERSION);
914 printf(
"the socan test program\n"
918 " **************** Configuration*****************\n"
919 " --interface,-i INTERFACE \n"
920 " Use INTERFACE for CAN communication, this option\n"
921 " can be given more than once to use more than one\n"
923 " --realtime READER-PRIORITY WRITER-PRIORITY\n"
924 " Use given realtime priorities for reader and writer\n"
926 " --leave [SECONDS]\n"
927 " for all functions that define CAN-objects, hold the\n"
928 " program just before close() is performed. All CAN\n"
929 " objects remain defined. End the program with CRTL-C in\n"
931 " --trace,-t LEVEL\n"
932 " set trace level, LEVEL is an integer 0..2 (default 0)\n"
933 " --errprintlevel,-E LEVEL\n"
934 " set errprint level, LEVEL is an integer 0..3 (default 1)\n"
935 " *************** command options ***************\n"
936 " --loop {no of loops}\n"
937 " run read, write, readnow or readmany in loop-mode\n"
938 " --loopdelay {delay}\n"
939 " delay each loop by the given number of seconds.\n"
940 " seconds may be a floating point number.\n"
941 " --sleep {seconds}\n"
942 " sleep a number of seconds before starting the test.\n"
943 " seconds may be a floating point number.\n"
944 " --quiet,-q {level}\n"
945 " Run read, write, readnow or readmany in quiet-mode\n"
946 " level may be 1 .. 5, meaning that each 10**(level-1)\n"
947 " events print a single character on the screen.\n"
948 " Level 0 means no printing at all.\n"
950 " Print a the timestamp for each sent or received\n"
953 " run read, readnow or readmany in statistic mode.\n"
954 " Print number of transmits and errors.\n"
955 " --maxlossrate [number]\n"
956 " print a warning when the ratio of lost CAN objects for\n"
957 " read functions is bigger than [number].\n"
959 " check sequence in --read, (must be used together with\n"
960 " --write in another sotest-task\n"
961 " --size,-s [bytes]\n"
962 " use [bytes] bytes to transfer and receive data\n"
963 " --count [number]\n"
964 " use [number] as initial number to write with -w\n"
966 " send alternating 8 bytes of 0xFF or 0x00 to test data\n"
969 " do remote-read or remote-write, implemented for\n"
970 " --write and --read\n"
972 " ignore the SOCAN_OLD-flag \n"
974 printf(
" ***************data transmission commands****************\n"
975 " --rwtest [object1] [port1] [object2] [port2] "
976 "[write-timeout] [read-timeout]\n"
977 " make a write-object (object1,port1) and a read-object\n"
978 " (object2,port2) with a timeout set for the 2nd object\n"
979 " then write 8 bytes (values 1 to 8) and read the 2nd\n"
980 " object (read immediately) and return the results\n"
981 " --write,-w [object] [port] [timeout]\n"
982 " write data (a running counter)\n"
983 " --writelater [object] [port] [timeout]\n"
984 " similar to write, but writelater returns immediately,\n"
985 " without waiting for the actual access of the CAN-bus.\n"
986 " Note: writelater returns only errors that are valid for\n"
987 " the PREVIOUS writelater !!!\n"
988 " --writelater-w [object] [port] [timeout]\n"
989 " the same as --writelater but do silently retry to write\n"
990 " when the driver returns a SOCAN_WAIT status.\n"
991 " --writeinhibit [object] [port] [timeout] [inhibit-time]\n"
992 " similar to writelater, but the CAN-object gets a timestamp\n"
993 " when it is transmitted. Inhibit-time is the minumum\n"
994 " time that has to pass before a new object is sent. This\n"
995 " concerns only writeinhibit combined with the loop-command.\n"
996 " In this case only about every [inhibit-time]\n"
997 " microseconds new data will be sent (note that the unit\n"
998 " for this parameter is microseconds, not milliseconds\n"
999 " --writertr [object] [port] [timeout]\n"
1000 " Just write an RTR frame on a CAN object.\n"
1001 " --read,-r [object] [port] [timeout]\n"
1002 " read data from an object (blocking).\n"
1003 " --readnow [object] [port] [timeout]\n"
1004 " read data from an object (immediately).\n"
1005 " --queue-read [port] [timeout] [object] {[object]}\n"
1006 " read more than one object via the signal-function in \n"
1007 " conjunction with the new queue-read operation\n"
1008 " together with --remote, all objects will be remote-read\n"
1011 printf(
" ******************** miscellaneous tests ****************\n"
1012 " --bitrate [port]\n"
1013 " get bitrate of a port\n");
1017#define MAX_INTERFACES 4
1019int main(
int argc,
char *argv[])
1025 {
"--help" , HELP },
1026 {
"-i" , INTERFACE },
1027 {
"--interface" , INTERFACE },
1028 {
"--leave" , LEAVE},
1029 {
"--realtime" , REALTIME},
1030 {
"--bitrate" , BITRATE},
1031 {
"--rwtest" , RWTEST},
1033 {
"--write" , WRITE},
1034 {
"--writelater" , WRITE_LATER},
1035 {
"--writelater-w", WRITE_LATER_W},
1036 {
"--writeinhibit", WRITE_INHIBIT},
1037 {
"--writertr" , WRITE_RTR},
1040 {
"--readnow" , READ_NOW},
1041 {
"--queue-read" , QUEUE_READ},
1043 {
"--loopdelay" , LOOPDELAY},
1044 {
"--sleep" , SLEEP},
1046 {
"--quiet" , QUIET},
1047 {
"--timestamp" , TIMESTAMP},
1048 {
"--stats" , STATS},
1049 {
"--maxlossrate" , MAXLOSSRATE},
1050 {
"--check" , CHECK},
1053 {
"--count" , COUNT},
1054 {
"--remote" , REMOTE},
1055 {
"--consistence" , CONSISTENCE},
1056 {
"--ignore_old" , IGNORE_OLD},
1058 {
"--trace" , TRACE},
1059 {
"-E" , ERRPRINTLEVEL},
1060 {
"--errprintlevel", ERRPRINTLEVEL},
1062 int opt_no=
sizeof(options) /
sizeof(
option);
1063 enum commands operation=CMD_NOTHING;
1065 char *interfaces[MAX_INTERFACES];
1067 int n[45], i, l, tracelevel= -1, errprintlevel= -1;
1072 double maxlossrate= -1;
1073 double loopdelay= 0;
1075 int countsize =
sizeof(int);
1079 int rt_prios[]= {-1, -1};
1084 my_exit(
"error, option/command missing\n");
1087 while(opt_index<argc)
1089 opt= match(argc, argv, &opt_index, options, opt_no);
1093 my_exit(
"unknown option: %s\n", argv[opt_index]);
1098 if (match_st(argc, argv, &opt_index, &st))
1099 my_exit(
"interface name missing!\n");
1100 if (interface_no >= MAX_INTERFACES)
1101 my_exit(
"too many interfaces given (more than %d)\n",
1103 interfaces[interface_no++]= st;
1108 rc= match_int(argc, argv, &opt_index, &(rt_prios[i]));
1110 my_exit(
"error, argument missing\n");
1112 my_exit(
"error, argument is not a number\n");
1116 rc= match_float(argc, argv, &opt_index, &leave);
1118 my_exit(
"the leave parameter is missing!\n");
1120 my_exit(
"the leave parameter is is not a number!\n");
1122 my_exit(
"the leave parameter must be positive\n");
1125 rc= match_int(argc, argv, &opt_index, &tracelevel);
1127 my_exit(
"the tracelevel parameter is missing!\n");
1129 my_exit(
"the tracelevel parameter is is not a number!\n");
1131 my_exit(
"trace level must be positive\n"
1132 "(input was %d)\n", tracelevel);
1135 rc= match_int(argc, argv, &opt_index, &errprintlevel);
1137 my_exit(
"the errprintlevel parameter is missing!\n");
1139 my_exit(
"the errprintlevel parameter is is not a number!\n");
1140 if (errprintlevel<0)
1141 my_exit(
"errprintlevel must be positive\n"
1142 "(input was %d)\n", errprintlevel);
1152 flag|= (T_CONSISTENCE | T_CHECK);
1157 flag|= T_IGNORE_OLD;
1160 rc= match_int(argc, argv, &opt_index, &loops);
1162 my_exit(
"the loop parameter is missing!\n");
1164 my_exit(
"the loop parameter is is not a number!\n");
1166 my_exit(
"loop-parameter should be greater than zero!\n"
1167 "(input was %ld)\n", loops);
1170 rc= match_float(argc, argv, &opt_index, &loopdelay);
1172 my_exit(
"the loopdelay parameter is missing!\n");
1174 my_exit(
"the loopdelay parameter is is not a number!\n");
1177 rc= match_float(argc, argv, &opt_index, &sleep);
1179 my_exit(
"the sleep parameter is missing!\n");
1181 my_exit(
"the sleep parameter is is not a number!\n");
1184 rc= match_int(argc, argv, &opt_index, &quietlevel);
1186 my_exit(
"the quiet parameter is missing!\n");
1188 my_exit(
"the quiet parameter is is not a number!\n");
1189 if ((quietlevel<0) || (quietlevel>5))
1190 my_exit(
"only quiet-levels 0 to 5 are allowed\n"
1191 "(input was %d)\n", quietlevel);
1200 rc= match_float(argc, argv, &opt_index, &maxlossrate);
1202 my_exit(
"the max loss rate parameter is missing!\n");
1204 my_exit(
"the max loss rate parameter is is not a number!\n");
1207 rc= match_int(argc, argv, &opt_index, &countsize);
1209 my_exit(
"the count parameter is missing!\n");
1211 my_exit(
"the count parameter is is not a number!\n");
1212 if ((countsize<1) || (countsize>8))
1213 my_exit(
"[bytes]-parameter must be between 1 and 8 !!\n");
1216 rc= match_int(argc, argv, &opt_index, &countstart);
1218 my_exit(
"the countstart parameter is missing!\n");
1220 my_exit(
"the countstart parameter is is not a number!\n");
1222 my_exit(
"[count]-parameter must be greater than 0 !!\n");
1225 if (operation!=CMD_NOTHING)
1226 my_exit(
"contradicting options\n");
1227 operation=CMD_BITRATE;
1228 rc= match_int(argc, argv, &opt_index, &(n[0]));
1230 my_exit(
"the port parameter is missing!\n");
1232 my_exit(
"the port parameter is is not a number!\n");
1235 if (operation!=CMD_NOTHING)
1236 my_exit(
"contradicting options\n");
1237 operation=CMD_RWTEST;
1240 rc= match_int(argc, argv, &opt_index, &(n[i]));
1242 my_exit(
"error, argument missing\n");
1244 my_exit(
"error, argument is not a number\n");
1252 if (operation!=CMD_NOTHING)
1253 my_exit(
"contradicting options\n");
1257 operation=CMD_WRITE;
break;
1259 operation=CMD_WRITE_LATER;
break;
1261 operation=CMD_WRITE_LATER_W;
break;
1263 operation=CMD_WRITE_INHIBIT;
break;
1265 operation=CMD_WRITE_RTR;
break;
1268 if (operation==CMD_WRITE_INHIBIT)
1272 rc= match_int(argc, argv, &opt_index, &(n[i]));
1274 my_exit(
"error, argument missing\n");
1276 my_exit(
"error, argument is not a number\n");
1281 if (operation!=CMD_NOTHING)
1282 my_exit(
"contradicting options\n");
1286 operation=CMD_READ;
break;
1288 operation=CMD_READ_NOW;
break;
1292 rc= match_int(argc, argv, &opt_index, &(n[i]));
1294 my_exit(
"error, argument missing\n");
1296 my_exit(
"error, argument is not a number\n");
1300 if (operation!=CMD_NOTHING)
1301 my_exit(
"contradicting options\n");
1302 operation= CMD_QUEUE_READ;
1305 while ((rc==0) && (last_valid_n<21))
1308 rc= match_int(argc, argv, &opt_index, &(n[last_valid_n]));
1309 switch(last_valid_n)
1313 my_exit(
"error, port missing\n");
1317 my_exit(
"error, timeout missing\n");
1321 my_exit(
"error, first object-id missing\n");
1332 if (interface_no==0)
1334 printf(
"Error, no interfaces defined\n");
1337 if (!init_socan(interfaces, interface_no,
1338 tracelevel, errprintlevel,
1339 rt_prios[0], rt_prios[1]))
1345 printf(
"error, no command given\n");
1351 test_simple_rw(n[0], n[1], n[2], n[3], n[4], n[5],
1355 case CMD_WRITE_LATER:
1356 case CMD_WRITE_LATER_W:
1357 case CMD_WRITE_INHIBIT:
1359 test_write(n[0], n[1], n[2], n[3],
1360 loops, loopdelay, sleep, leave, quietlevel,
1362 countsize,countstart,
1367 test_read(n[0], n[1], n[2],
1368 loops, loopdelay, sleep, leave,
1369 maxlossrate, quietlevel,
1370 (operation==CMD_READ_NOW),
1373 case CMD_QUEUE_READ:
1374 test_queue_read(n[0], n[1], n+2, last_valid_n-1,
1375 loops, loopdelay, sleep, leave, maxlossrate,
1376 quietlevel, countsize, flag);
socan_rc socan_user_area(unsigned char port, unsigned short cob, void **area)
bool socan_close(socan_hdl h)
socan_rc socan_write_inhibit(socan_hdl hdl, unsigned char port, unsigned short cob, const void *data, unsigned long *inhibit_time)
char * socan_str_rc(socan_rc rc)
socan_rc socan_port_bitrate(unsigned char port, unsigned int *bitrate)
socan_rc socan_read(socan_hdl hdl, unsigned char port, unsigned short cob, void *data)
socan_rc socan_obj_ts(unsigned char port, unsigned short cob, unsigned long *ts)
socan_rc socan_use_queue(unsigned char port, unsigned short cob)
socan_rc socan_readnow(socan_hdl hdl, unsigned char port, unsigned short cob, void *data)
socan_rc socan_set_inhibit(unsigned char port, unsigned short cob, unsigned long inhibit_time)
socan_rc socan_write(socan_hdl hdl, unsigned char port, unsigned short cob, const void *data)
bool socan_rc_is_error(socan_rc rc)
socan_hdl socan_open(void)
socan_rc socan_queue_read(socan_hdl hdl, unsigned char *port, unsigned short *cob, void *data)
socan_rc socan_add_obj(socan_hdl hdl, unsigned char port, unsigned short cob, unsigned char length, unsigned int tmo_ms, socan_obj_type type)
socan_rc socan_writelater(socan_hdl hdl, unsigned char port, unsigned short cob, const void *data)
socan_rc socan_new_user_area(unsigned char port, unsigned short cob, unsigned int size, void **area)
c header file for socan object layer library.