-
USB Receiving a Word
Help, brain burnout here with Easyhid and words LOL
I want to send a Word value of decimal 1000
I am sending from VB two bytes of data 10 00:
BufferOut(0) = 0
BufferOut(1) = 10
BufferOut(2) = 00
In PBP I am receiving them fine as bytes
Byte1=usbbuffer(0)
Byte2=usbbuffer(1)
Now I want to pop these into a Word Value within PBP code but using
WordData.HighByte=Byte1
WordData.LowByte=Byte2
But it takes the value and stores then as Hex Byte1 gets stored as 0A and Byte 2 gets stored as 00 and hence when I end up with 2560 in Decimal stored and not 1000.
Now the question is, do I have to convert my Decimal 1000 to hex at the VB end and send or can I convert in my PBP code after receiving?.
If using Serial data and Receiving using Hserin I just simply
HSerin [WAIT("$"),DEC4 WordData]
And would love to do that with USB as well!
I am probs missing something so obvious here LOL
Regards
Sean.
-
Hi,
Have you thought about that 1000 DEC is HighByte=3 and LowByte=232 and not 10 00?
What you get is actually correct if you look at following:
00001010 00000000=2560 HighByte=10 DEC LowByte=0
00000011 11101000=1000 HighByte=3 DEC LowByte=232
My suggestion is to split the word in VB using a different method.
-
Ah now I see of course.
So in my VB prog I will take the value say 1000
Splt it down to 16bits
0000001111101000
Split again to high and low 8 bits
00000011 = 3
11101000 =232
Then send dec value of each set of 8 bits.
Excellent!
Regards
Sean.