canfdtest: make use of bool
parent
146fd949c9
commit
104072f038
27
canfdtest.c
27
canfdtest.c
|
|
@ -24,6 +24,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -54,11 +55,11 @@ static int exit_sig;
|
||||||
static int inflight_count = CAN_MSG_COUNT;
|
static int inflight_count = CAN_MSG_COUNT;
|
||||||
static canid_t can_id_ping = CAN_MSG_ID_PING;
|
static canid_t can_id_ping = CAN_MSG_ID_PING;
|
||||||
static canid_t can_id_pong = CAN_MSG_ID_PONG;
|
static canid_t can_id_pong = CAN_MSG_ID_PONG;
|
||||||
static int has_pong_id;
|
static bool has_pong_id;
|
||||||
static int is_can_fd;
|
static bool is_can_fd;
|
||||||
static int bit_rate_switch;
|
static bool bit_rate_switch;
|
||||||
static int msg_len = CAN_MSG_LEN;
|
static int msg_len = CAN_MSG_LEN;
|
||||||
static int is_extended_frame_format;
|
static bool is_extended_frame_format;
|
||||||
|
|
||||||
static void print_usage(char *prg)
|
static void print_usage(char *prg)
|
||||||
{
|
{
|
||||||
|
|
@ -312,7 +313,7 @@ static int can_echo_dut(void)
|
||||||
static int can_echo_gen(void)
|
static int can_echo_gen(void)
|
||||||
{
|
{
|
||||||
struct canfd_frame *tx_frames;
|
struct canfd_frame *tx_frames;
|
||||||
int *recv_tx;
|
bool *recv_tx;
|
||||||
struct canfd_frame rx_frame;
|
struct canfd_frame rx_frame;
|
||||||
unsigned char counter = 0;
|
unsigned char counter = 0;
|
||||||
int send_pos = 0, recv_rx_pos = 0, recv_tx_pos = 0, unprocessed = 0, loops = 0;
|
int send_pos = 0, recv_rx_pos = 0, recv_tx_pos = 0, unprocessed = 0, loops = 0;
|
||||||
|
|
@ -334,7 +335,7 @@ static int can_echo_gen(void)
|
||||||
/* still send messages */
|
/* still send messages */
|
||||||
tx_frames[send_pos].len = msg_len;
|
tx_frames[send_pos].len = msg_len;
|
||||||
tx_frames[send_pos].can_id = can_id_ping;
|
tx_frames[send_pos].can_id = can_id_ping;
|
||||||
recv_tx[send_pos] = 0;
|
recv_tx[send_pos] = false;
|
||||||
|
|
||||||
for (i = 0; i < msg_len; i++)
|
for (i = 0; i < msg_len; i++)
|
||||||
tx_frames[send_pos].data[i] = counter + i;
|
tx_frames[send_pos].data[i] = counter + i;
|
||||||
|
|
@ -367,7 +368,7 @@ static int can_echo_gen(void)
|
||||||
/* own frame */
|
/* own frame */
|
||||||
if (rx_frame.can_id == can_id_ping) {
|
if (rx_frame.can_id == can_id_ping) {
|
||||||
err = compare_frame(&tx_frames[recv_tx_pos], &rx_frame, 0);
|
err = compare_frame(&tx_frames[recv_tx_pos], &rx_frame, 0);
|
||||||
recv_tx[recv_tx_pos] = 1;
|
recv_tx[recv_tx_pos] = true;
|
||||||
recv_tx_pos++;
|
recv_tx_pos++;
|
||||||
if (recv_tx_pos == inflight_count)
|
if (recv_tx_pos == inflight_count)
|
||||||
recv_tx_pos = 0;
|
recv_tx_pos = 0;
|
||||||
|
|
@ -411,7 +412,7 @@ int main(int argc, char *argv[])
|
||||||
int echo_gen = 0;
|
int echo_gen = 0;
|
||||||
int opt, err;
|
int opt, err;
|
||||||
int enable_socket_option = 1;
|
int enable_socket_option = 1;
|
||||||
int filter = 0;
|
bool filter = false;
|
||||||
|
|
||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
signal(SIGHUP, signal_handler);
|
signal(SIGHUP, signal_handler);
|
||||||
|
|
@ -420,15 +421,15 @@ int main(int argc, char *argv[])
|
||||||
while ((opt = getopt(argc, argv, "bdef:gi:l:o:s:vx?")) != -1) {
|
while ((opt = getopt(argc, argv, "bdef:gi:l:o:s:vx?")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'b':
|
case 'b':
|
||||||
bit_rate_switch = 1;
|
bit_rate_switch = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
is_can_fd = 1;
|
is_can_fd = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
is_extended_frame_format = 1;
|
is_extended_frame_format = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
|
|
@ -449,7 +450,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
can_id_pong = strtoul(optarg, NULL, 16);
|
can_id_pong = strtoul(optarg, NULL, 16);
|
||||||
has_pong_id = 1;
|
has_pong_id = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
|
|
@ -461,7 +462,7 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
filter = 1;
|
filter = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue