I've read dozens of posts about OpenComPort and handling incoming data but to no avail. Any puzzle solvers out there?
I'm trying to control a Russound ST2 dual tuner radio via HS scripts. Also, I am still using HS v1.7. Sending data to control the radio is easy. Getting incoming data that I can do anything with isn't. The ST2 communicates in Hex and has a start bit of F0 and an end bit of F7. The second to last bit is a check sum. It sends two streams, one for each tuner.
I use the following to open the comport (5) with no problem:
e=hs.OpenComPort(5,"19200,N,8,1",0,"datastring.txt","")
In a text file called datastring.txt I have the following:
strdata = hs.GetComPortData(5)
hs.writelog "Com 5 Raw data", strdata
In looking at Portmon and my hs log I see similar but strange results. Here's the problem.
First, the incoming data for each tuner is delivered in 5 separate strings each, a total of 10 since there are 2 tuners. I would have expected one long string, or at least 2 long strings, one for each tuner. I've tried using mode 1 in the OpenComPort statement and adding the term parameter for the end bit F7 but keep getting an error message "wrong number of arguments or invalid property assignment"
Each string is 14 characters long except for the last which is 6. I've listed what is returned in hex, ascii via portmon and what is shown in the hs log. I only used writelog to see what data is being received by HS.
For Tuner 1:
string 1 Hex: F0 7D 00 79 00 7D 00 00 02 01 01 02 01 01 - Last Char=49
string 1 ascii: .}.y.}........
string 1 hs log: a character I don't recognize, sort of a o with an * over it followed by }
string 2 Hex: 00 00 01 00 28 00 10 00 00 31 30 33 2E 33 - Last Char=57
string 2 ascii: ....(....103.3
string 2 hs log: totally blank (don't know why its blank???)
string 3 Hex: 20 4D 48 7A 20 46 4D 00 5A 5A 5A 5A 5A 5A - Last Char=65
string 3 ascii: MHz FM ZZZZZZ
string 3 hs log: MHz FM
string 4 Hex: 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A - Last Char=65
string 4 ascii: ZZZZZZZZZZZZZZ
string 4 hs log: ZZZZZZZZZZZZZZ
string 5 Hex: 5A 5A 5A 5A 24 F7 - Last Char=55
string 5 ascii: ZZZZ'.
string 5 hs log: ZZZZ* followed by the divided by symbol
Tuner 2 is the same except it shows what station it is tuned to.
So, any ideas how I can end up with a variable to show what each tuner's station is set to? Even if I could end up with two 48 bit strings (one for each tuner) I could then parse the data and create variables. Or even if I could somehow create variables for each of the five strings I could parse those.
I know this is strange but would appreciate any thoughts from the serial gurus.
I'm trying to control a Russound ST2 dual tuner radio via HS scripts. Also, I am still using HS v1.7. Sending data to control the radio is easy. Getting incoming data that I can do anything with isn't. The ST2 communicates in Hex and has a start bit of F0 and an end bit of F7. The second to last bit is a check sum. It sends two streams, one for each tuner.
I use the following to open the comport (5) with no problem:
e=hs.OpenComPort(5,"19200,N,8,1",0,"datastring.txt","")
In a text file called datastring.txt I have the following:
strdata = hs.GetComPortData(5)
hs.writelog "Com 5 Raw data", strdata
In looking at Portmon and my hs log I see similar but strange results. Here's the problem.
First, the incoming data for each tuner is delivered in 5 separate strings each, a total of 10 since there are 2 tuners. I would have expected one long string, or at least 2 long strings, one for each tuner. I've tried using mode 1 in the OpenComPort statement and adding the term parameter for the end bit F7 but keep getting an error message "wrong number of arguments or invalid property assignment"
Each string is 14 characters long except for the last which is 6. I've listed what is returned in hex, ascii via portmon and what is shown in the hs log. I only used writelog to see what data is being received by HS.
For Tuner 1:
string 1 Hex: F0 7D 00 79 00 7D 00 00 02 01 01 02 01 01 - Last Char=49
string 1 ascii: .}.y.}........
string 1 hs log: a character I don't recognize, sort of a o with an * over it followed by }
string 2 Hex: 00 00 01 00 28 00 10 00 00 31 30 33 2E 33 - Last Char=57
string 2 ascii: ....(....103.3
string 2 hs log: totally blank (don't know why its blank???)
string 3 Hex: 20 4D 48 7A 20 46 4D 00 5A 5A 5A 5A 5A 5A - Last Char=65
string 3 ascii: MHz FM ZZZZZZ
string 3 hs log: MHz FM
string 4 Hex: 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A - Last Char=65
string 4 ascii: ZZZZZZZZZZZZZZ
string 4 hs log: ZZZZZZZZZZZZZZ
string 5 Hex: 5A 5A 5A 5A 24 F7 - Last Char=55
string 5 ascii: ZZZZ'.
string 5 hs log: ZZZZ* followed by the divided by symbol
Tuner 2 is the same except it shows what station it is tuned to.
So, any ideas how I can end up with a variable to show what each tuner's station is set to? Even if I could end up with two 48 bit strings (one for each tuner) I could then parse the data and create variables. Or even if I could somehow create variables for each of the five strings I could parse those.
I know this is strange but would appreciate any thoughts from the serial gurus.
Comment