¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Trying to parse RS232


 

Here's a snippet of some code that will do what you want. The problem you were having is that you thought that \x was actually part of the character string you were receiving from the device when actually that's just debugger adding \x to signify an unprintable ascii character. This leaves out any searching for the correct string etc.

MAKESTRING(temp$, "%02X%02X", BYTE(rx$,3), BYTE(rx$,2));
LAMP = HEXTOI(temp$);

--- In Crestron@..., "madbanzai88" <danielteed@...> wrote:

Thanks for the replies, basically this is how a Hitachi projector returns its lamp hours, I know the lamp has currently done 974 hours.
Which in HEX is 3CE, so I want to strip out everything else and pass out 3CE to another module to convert the hex to decimal to get 974 (or whatever the hours our).

Matt you said I'm having issues because I'm starting my mid after the length of the string, how can I correct this?

--- In Crestron@..., "madbanzai88" <danielteed@> wrote:

Hi All,

I would really appreciate some help, as I can't see what I'm doing wrong.

I've got an RS232 command "&#92;x1D&#92;xCE&#92;x03" that I want to output as 03CE.

Here's what I have so far:

if (Find("&#92;x1D", FromDevice$))
{
Stored$ = FromDevice$;
Trash$ = remove("&#92;x1D", Stored$); // Stored$ = &#92;xCE&#92;x03
string1 = mid(Stored$,3,3);

output$ = string1;
}
I've done this to test, to see if I could get the middle of Stored$.
So I would expect output$ to be "E&#92;", but its coming out empty. What am I doing wrong?

Join [email protected] to automatically receive all group messages.