Hi
FC6 (PIC18F2550)
i try in a simply New Clear Test Project with RS232 sending a Fix String like this
i want to send a hex String ( 9F3C7F ) from 3 int numbers like this
159 = 9F
60 = 3C
127 = 7F
so before i call the macro RS232 sendstring..
i insert a "calculation"
msg = NumberToHex$(159)
msg = msg + NumberToHex$(60)
msg = msg + NumberToHex$(127)
... the compiler will stop with error code 1
what make i wrong?
is this a wrong way to "add" ?
Best wishes!! and Thank you!
Rudi
Edit : 1
ps..
I have try ( RS232) with
sendchar (0x9F )
sendchar (0x3C )
sendchar (0x7F )
this is a option for me ..
but i need the 3 hex values in one send time...
how i can managed this as a send a Array?
..sendchar (0x9F, 0x3C, 0x7F )
does not go ...
Thanks for any Tip!
Best wishes!
Rudi
String = NumberToHex$
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: String = NumberToHex$
Hi Rudi
You are correct, we have a bug there and will resolve it as soon as we can.
The bug happens when you attempt to concatenate the NumberToHex$() with another string.
As a temporary fix you could try:
Msg1 = NumberToHex$(159)
Msg2 = NumberToHex$(60)
Msg3 = NumberToHex$(60)
Msg = Msg1 + Msg2 + Msg3
However, I don’t think the NumberToHex$() is ideal for what you are trying to do, as NumberToHex$(159) will return “0x9F”, so you will also need to strip off the leading “0x”
characters from the string.
You could try converting each byte into two hex characters.
Here’s some code to think about:
Leigh
You are correct, we have a bug there and will resolve it as soon as we can.
The bug happens when you attempt to concatenate the NumberToHex$() with another string.
As a temporary fix you could try:
Msg1 = NumberToHex$(159)
Msg2 = NumberToHex$(60)
Msg3 = NumberToHex$(60)
Msg = Msg1 + Msg2 + Msg3
However, I don’t think the NumberToHex$() is ideal for what you are trying to do, as NumberToHex$(159) will return “0x9F”, so you will also need to strip off the leading “0x”
characters from the string.
You could try converting each byte into two hex characters.
Here’s some code to think about:
Code: Select all
first_hex_character = ((number >> 4) AND 0x0f) + ‘0’
If first_hex_character > ‘9’
first_hex_character = first_hex_character + 7
sendchar(first_hex_character)
second_hex_character = (number AND 0x0f) + ‘0’
If second_hex_character > ‘9’
second_hex_character = second_hex_character + 7
sendchar(second _hex_character)
Re: String = NumberToHex$
Hi Leigh,
thank you for your Time and Help .
I will try your example ..
the option
As a temporary fix :
Msg1 = NumberToHex$(159)
Msg2 = NumberToHex$(60)
Msg3 = NumberToHex$(60)
Msg = Msg1 + Msg2 + Msg3
i have try in one option - i am not sure just in Time ... -.. but i think the data was then
"9F 3C 7F"
and i need the "string" as
"9F3C7F" ... at the Receiver i can not change / translate the data ( are fix hardware )
i will try again...
for me temporally for work ... ...
i have change string in char ( receivestring.. receiveChar ) in RS232.
If the bug can be fixed in the next... updates, maybe I'll go back to the String variant.
Maybe it can also be fixed to the null string. "RS232 unable to receive "0" byte"
http://w.matrixmultimedia.com/mmforums/ ... 54&t=14345
That would be nice Your Team make great Work! Thank you!
Best wishes from Germany!
Rudi
thank you for your Time and Help .
I will try your example ..
the option
As a temporary fix :
Msg1 = NumberToHex$(159)
Msg2 = NumberToHex$(60)
Msg3 = NumberToHex$(60)
Msg = Msg1 + Msg2 + Msg3
i have try in one option - i am not sure just in Time ... -.. but i think the data was then
"9F 3C 7F"
and i need the "string" as
"9F3C7F" ... at the Receiver i can not change / translate the data ( are fix hardware )
i will try again...
for me temporally for work ... ...
i have change string in char ( receivestring.. receiveChar ) in RS232.
If the bug can be fixed in the next... updates, maybe I'll go back to the String variant.
Maybe it can also be fixed to the null string. "RS232 unable to receive "0" byte"
http://w.matrixmultimedia.com/mmforums/ ... 54&t=14345
That would be nice Your Team make great Work! Thank you!
Best wishes from Germany!
Rudi