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

Display Binary Data #2

Open
williamesp2015 opened this issue Jul 21, 2016 · 5 comments
Open

Display Binary Data #2

williamesp2015 opened this issue Jul 21, 2016 · 5 comments

Comments

@williamesp2015
Copy link

Hi @krzychb , I tested sending binary data (signed integer) and display multi-channel chart.
int16_t samples[Sample number];
uint8_t u8Data[Sample number*2];
......
u8Data[0]=samples[0]/256;//high byte
u8Data[1]=samples[0]%256;
.....
webSocket.sendBIN(socketNumber, u8Data, NN);
/////////// index.html
.........
connection = new WebSocket(host, ['arduino']);
connection.binaryType = 'arraybuffer';
........
var buffer = new Uint8Array(message.data);
var dataview=new Int16Array(NN);
dataview[0]=(buffer[0]<<8)+buffer[1];
...............
scopeSamples1.push({x: xVal, y:dataview[0]});
...............

@krzychb
Copy link
Owner

krzychb commented Jul 21, 2016

Hi @williamesp2015,

Thank you for update on developments with binary transfer and code snippets!

To skip copying data from samples to u8Data, did you consider something like:

webSocket.sendBIN(socketNumber, samples, NN/2);

I am currently busy with another project but return to this one soon 😄

@williamesp2015
Copy link
Author

Hi @krzychb , Thank you for your comment. I couldn't do that because the function accept only unsigned byte.
bool sendBIN(uint8_t num, const uint8_t * payload, size_t length);

@krzychb
Copy link
Owner

krzychb commented Jul 21, 2016

@williamesp2015,

You are right. I did not consider the data type.
In such case I would cast uint16_t * data type to uint8_t * :

webSocket.sendBIN(socketNumber, (uint8_t *) samples, NN);

Krzysztof

@williamesp2015
Copy link
Author

Hi Krzysztof. I want to remove Adjustable sampling threshold and sampling rate and anything that slowing visualizing highest speed EspScopeA0. Please advice. Thank you

@krzychb
Copy link
Owner

krzychb commented Aug 23, 2016

Hi @williamesp2015,

This looks like version Bravo that is already on my To Do list 😄

Have you been thinking about setting a fixed number of samples and threshold or rather introducing a separate command to set them up?

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

2 participants