Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CaSchmidt
Copy link

Hi Oliver,
as discussed, the implementation of reading PDU data from binary file instead of STDIN.
-- Carsten

return 0;
}

if( (fd = open(filename, O_RDONLY)) == -1 ) {
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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 ) {
Copy link
Member

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);
Copy link
Member

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]'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants