-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read PDU to send from binary file. #419
base: master
Are you sure you want to change the base?
Conversation
return 0; | ||
} | ||
|
||
if( (fd = open(filename, O_RDONLY)) == -1 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no assignments in if-statements
please adopt the coding style with parenthesis and spaces
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n"); | ||
fprintf(stderr, "The pdu data is expected on STDIN in space separated ASCII hex values.\n"); | ||
fprintf(stderr, "(*) = Use '-t %s' to set N_As to zero for Linux version 5.18+\n", ZERO_STRING); | ||
fprintf(stderr, "\n"); | ||
} | ||
|
||
ssize_t read_binary_file(void *buffer, const size_t siz_buffer, const char *filename) | ||
{ | ||
int fd = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for initialization
ssize_t read_binary_file(void *buffer, const size_t siz_buffer, const char *filename) | ||
{ | ||
int fd = -1; | ||
ssize_t num_read = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dito
@@ -285,13 +310,15 @@ int main(int argc, char **argv) | |||
exit(1); | |||
} | |||
|
|||
if( buflen < 1 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (buflen > 0) { ... ??
additional the indention seems wrong
@@ -227,6 +248,10 @@ int main(int argc, char **argv) | |||
} | |||
break; | |||
|
|||
case 'i': | |||
buflen = read_binary_file(&buf[0], sizeof(buf), optarg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use 'buf' instead of '&buf[0]'
Hi Oliver,
as discussed, the implementation of reading PDU data from binary file instead of STDIN.
-- Carsten