hi i want to send a pack with 3 bytes every time. is this ok?
Qt Code:
QByteArray g; g.insert(0,0x22); g.insert(1,0x2e); g.insert(2,1000); serial.write(g);To copy to clipboard, switch view to plain text mode
hi i want to send a pack with 3 bytes every time. is this ok?
Qt Code:
QByteArray g; g.insert(0,0x22); g.insert(1,0x2e); g.insert(2,1000); serial.write(g);To copy to clipboard, switch view to plain text mode
No.is this ok?
1000 with this syntax is not hex but decimal, and 1000 is more than one byte. 1000 in hex is 0x3e8 (it spans over 2 bytes).
So your protocol will have to accommodate sending values spanning over more than one byte.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
QJak (16th April 2018)
thanks, you are right. if for that i write g.insert(2, 250), is it ok?
then g (QByteArray) is prepare for sending?
Depends what "Ok" means for you.thanks, you are right. if for that i write g.insert(2, 250), is it ok?
250 is decimal not hex, but it still might be ok if the value is value you want (you can represent any of the values in any numerical base).
But 250 is not 1000 so I don't know what is the consequence for your code.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Bookmarks