Serial interface binary communication #314
Replies: 5 comments
-
Posted at 2014-09-19 by @gfwilliams Hi,
To do it 'nicely', I'd use Typed Arrays. The code would look a bit like:
You don't have to be 'aligned' either. You can do:
Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-20 by user48681 Thanks, I'll try it out and report :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-20 by user48681 One more thing, when reading data using the .on('data', function(data) {...}), do I need to create a buffer out of the string? Is the data always string? The docs seem to say so |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-20 by user48681 I can confirm that the sending works fine and I get responses back :) Thanks again |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-20 by @gfwilliams Great, glad it's going!
Yes, the data is always a string. You can use it as-is using |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-19 by user48681
How do you send binary messages that need to be specific in size?
For example I need to send 0x1 as 16 bits or other such combinations. I suspect sending it as a number would always send over 32bit integers?
Is there an elegant way to construct messages that consist of bytes/words/ints that you'd individually add together or do I have to build a string out of the values?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions