Skip to content
Snippets Groups Projects
Commit c889de09 authored by Jonas Höppner's avatar Jonas Höppner
Browse files

rs485echo: Add 'fake' data option, to send n-times 0xFF instead of random data

parent ac2cad53
No related branches found
No related tags found
1 merge request!243remote-station: Add Makefile to create self installation script
......@@ -356,6 +356,7 @@ void help()
printf(" -c Enable rtscts flowcontrol, not to be used in RS485 mode\n");
printf(" -d s Select serial port specified by device name s (default: /dev/ttymxc2)\n");
printf(" -e Echo mode, wait for data and echo it back\n");
printf(" -f Number 'fake' bytes in the random string to send, instead of real random data N bytes at the end of the package are replaces with 0xFF.\n");
printf(" -n Do not use RS485 mode\n");
printf(" -o x Set receive timeout to x milliseconds (default: 1000)\n");
printf(" -r x Repeat send and receive x times (default: 1), use 0 for forever.\n");
......@@ -394,6 +395,7 @@ main(int argc, /* number of command line parameters */
int byte_count = 0;
int send_delay = 300;
int receive_sleep = 0;
int fake_data_len = 0;
char received_byte;
int received_state_bytes = 0; // Number of bytes received in current state
int data_length = 0;
......@@ -406,15 +408,16 @@ main(int argc, /* number of command line parameters */
int opt_device_name = 0, opt_repetitions = 0, opt_bytes = 0,
opt_timeout = 0, opt_baudrate = 0, opt_nors485 = 0, opt_pingpong = 0,
opt_delaytime = 0, opt_verbose = 0, opt_rtscts = 0, opt_receive_sleep = 0,
opt_tx_only = 0;
opt_tx_only = 0, opt_fake_data_len = 0;
char *str_device_name, *str_repetitions, *str_bytes, *str_timeout,
*str_baudrate, *str_delaytime, *str_receive_sleep;
*str_baudrate, *str_delaytime, *str_receive_sleep, *str_fake_data_len;
option_t options[] = {
{"b:", &opt_bytes, &str_bytes},
{"c", &opt_rtscts, NULL},
{"d:", &opt_device_name, &str_device_name},
{"e", &opt_pingpong, NULL},
{"f:", &opt_fake_data_len, &str_fake_data_len},
{"n", &opt_nors485, NULL},
{"o:", &opt_timeout, &str_timeout},
{"r:", &opt_repetitions, &str_repetitions},
......@@ -487,6 +490,9 @@ main(int argc, /* number of command line parameters */
exit(1);
}
}
if (opt_fake_data_len){
fake_data_len = atoi(str_fake_data_len);
}
if (opt_verbose){
verbose = TRUE;
......@@ -495,6 +501,9 @@ main(int argc, /* number of command line parameters */
// Perform global test setup
setup();
if ( fake_data_len > message->length)
fake_data_len = message->length;
tst_resm(TINFO, "Starting RS485 echo test%s", echo_mode?" in echo mode.":".");
if (!echo_mode)
......@@ -512,6 +521,10 @@ main(int argc, /* number of command line parameters */
// Generate random string for message
random_string(message->data, message->length);
// Replace part of the random string with dummy data
for(int i = 0; i < fake_data_len; i ++)
message->data[message->length-1-i] = 0xFF;
tst_resm(TINFO, "Cycle %d data (first 1000 bytes): %.1000s%s",
cycle_count+1, message->data, message->length > 1000 ? "[...]" : "");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment