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

how to make longer packet lengths #7

Open
nindidooo opened this issue Nov 30, 2016 · 2 comments
Open

how to make longer packet lengths #7

nindidooo opened this issue Nov 30, 2016 · 2 comments

Comments

@nindidooo
Copy link

I'm trying to send a string of up to 54 characters from master to slave.

The characters are integers from 0 to 1000. Could you tell me how to do this?

@miketedeschi
Copy link

miketedeschi commented Nov 30, 2016 via email

@majenkotech
Copy link
Contributor

majenkotech commented Nov 30, 2016

By default you already have 250 bytes in the message buffer. That is more than enough for 54 characters.

If it's just a normal text string you can:

icsc.send(20, 'F', myString);

This is the same as:

icsc.send(20, 'F', myString, strlen(myString));

If it is an array of byte values you need to include the size of the array:

icsc.send(20, 'F', myData, 54);

For larger data types you need to cast it and make sure you give it the byte count. For 16-bit integers:

icsc.send(20, 'F', (uint8_t *)myData, 108);

sizeof() is useful for this, since it gives the byte size (as long as it's in the same scope as the definition of the array since it's calculated at compile time, not runtime):

icsc.send(20, 'F', (uint8_t *)myData, sizeof(myData));

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

No branches or pull requests

3 participants