NAD delimeter Help
mncchartier
Posts: 68
I am working on an NAD VISO FIVE and trying to parse the buffer and can not figure out the response termination.
I have this right now just for testing with the power commands
I never get into the While Statement. I receive this in the diag window
Line 1 (22:31:05):: 2
Line 2 (22:31:05):: Command Sent; #1#21#21^A#2#212#13
Line 3 (22:31:10):: cBuffer #1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^@#2#211#1#205^D#2#178#1#20'^@#2#196#1#20(^B#2#193#1#20!^B#2#200#1#20#1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^
Line 4 (22:31:10):: cBuffer #1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^@#2#211#1#205^D#2#178#1#20'^@#2#196#1#20(^B#2#193#1#20!^B#2#200#1#20#1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^
Line 5 (22:31:12):: NO RESPONSE RECEIVED; #1#21#21^A#2#212#13 SENDING NEXT CMD
Line 6 (22:31:21):: 1
Line 7 (22:31:21):: Command Sent; #1#21#21^@#2#213#13
Line 8 (22:31:22):: cBuffer #1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^@#2#211#1#205^D#2#178#1#20'^@#2#196#1#20(^B#2#193#1#20!^B#2#200#1#20#1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^
Line 9 (22:31:28):: NO RESPONSE RECEIVED; #1#21#21^@#2#213#13 SENDING NEXT CMD
I have this right now just for testing with the power commands
DEFINE_START CREATE_BUFFER dvNADViso2, cBUFFER DEFINE_EVENT DATA_EVENT[dvNADViso2] { ONLINE: { SEND_COMMAND dvNADViso2 , "'SET BAUD 9600,8,N,1'" CLEAR_BUFFER cBUFFER } STRING: { cBUFFER = "cBUFFER, DATA.TEXT" SEND_STRING 0, "'cBuffer ', cBUFFER" WHILE (FIND_STRING (cBUFFER,"13",1)) { SEND_STRING 0, "'cBuffer in While', cBUFFER" DISPMSG = REMOVE_STRING(cBUFFER,"13",1) SEND_STRING 0, "'Response; ', DISPMSG" } } }
I never get into the While Statement. I receive this in the diag window
Line 1 (22:31:05):: 2
Line 2 (22:31:05):: Command Sent; #1#21#21^A#2#212#13
Line 3 (22:31:10):: cBuffer #1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^@#2#211#1#205^D#2#178#1#20'^@#2#196#1#20(^B#2#193#1#20!^B#2#200#1#20#1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^
Line 4 (22:31:10):: cBuffer #1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^@#2#211#1#205^D#2#178#1#20'^@#2#196#1#20(^B#2#193#1#20!^B#2#200#1#20#1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^
Line 5 (22:31:12):: NO RESPONSE RECEIVED; #1#21#21^A#2#212#13 SENDING NEXT CMD
Line 6 (22:31:21):: 1
Line 7 (22:31:21):: Command Sent; #1#21#21^@#2#213#13
Line 8 (22:31:22):: cBuffer #1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^@#2#211#1#205^D#2#178#1#20'^@#2#196#1#20(^B#2#193#1#20!^B#2#200#1#20#1#20#20VISO FIVE#2L#1#20#21^A#2#213#1#20#23#241#2#227#1#20#24^
Line 9 (22:31:28):: NO RESPONSE RECEIVED; #1#21#21^@#2#213#13 SENDING NEXT CMD
0
Comments
Also this is screwing me up. I do power on I can filter that no problem, but power off I get the following
Line 15 (10:25:16):: Response; $01$14$15^@$02$D6$01$14$15^@$02$D6$0D
The ^@ is causing issues. $01 is the $14 means it is a response, $15 is Power, then it is suppose to be a value but I get ^@, which I can not decipher. This should be 94,64 decimal or 40,41 hex
That?s what you are getting.
^ (ASCII) = 94 (decimal) = $5E (hex) and
@ (ASCII) = 64 (decimal) = $40 (hex)
You can look at it as ASCII, decimal, or hex. It?s all the same thing when you boil it down to 1s and 0s.
So I should be more like
I get
#1#20#24^@#2
1 = start of response
20 = response command
24 = Mute function
^ = "94"
@ = "64"
The 94 means the next item is encoded and I need to do a bitwise AND 191 with it. This is where I have the issue. I have this and it is not working.
But I can do this fine, so it is how do I get the Dec value out of the CHR values,
At this point DISPMSG is the data all checksums and other bits are removed, so the 94 says the next thing is encoded and needs to BAND 191.
nData is an INTEGER
If it is -15 I am getting 241 in the SEND_STRING
By definition an INTEGER is unsigned so you won?t get negative numbers.
SINTEGERs are signed.
Negative numbers are represented by using the 2?s compliment and 241 is the 2?s compliment of -15 when using 8 bit logic.
Should give me the right results.
2?s compliment = 1?s compliment + 1
Anything (8 bit) BAND $FF doesn?t do anything to Anything, it still equals Anything.
Thanks for your help, I have a lot to learn and am waiting to go to training
I can get the appropriate values if the number is encoded but if it is not encoded I can not get the approriate value.
Line 15 (17:40:47):: Device_ID=VISO FIVE
Line 16 (17:40:47):: Power=1
Line 17 (17:40:47):: VOLUME FULL; #213#1#20#23#241#2
Line 18 (17:40:47):: VOLUME FULL; #241#2
Line 19 (17:40:47):: VOLUME LENGHT 2
Line 20 (17:40:47):: Volume Encoded Data; #241
Line 21 (17:40:47):: Volume=-241
Line 22 (17:40:47):: Mute=0
Line 23 (17:40:47):: Input=0
Line 24 (17:40:47):: Audio_Signal=1
Line 25 (17:40:47):: Surround_Mode=1
Line 26 (17:40:47):: Bass=2
Line 27 (17:40:47):: Trebel=0
Line 28 (17:40:47):: Tone_Defeat=0
As you can see here I can get the Bass value but that was encoded and I did not have to do anything to it after the BAND 191. When it is not encoded such as a volume level of -15 as shown above I can not get that value. So here is what is happening in that section. I have tried with just ATOI and also the TYPE_CAST as you see there and I can not get it to work out.
So if I was going to set the level at -15 then I would send:
1, 21, 23, 241, 2, 226
which is start:
start, command (21 is set), function (23 is volume, 241 is value, checksum flag, checksum
If I had to shoot in the dark I would treat everything with the sign bit set (the most significant bit) as a negative value and go from there.
If you are getting a value back that is greater than 127 (which means the most significant bit [the sign bit] must be set) then you should treat that number as the 2?s compliment representation of a negative number. If the number is less than 128 then the sign bit must be 0 so the number is positive and can be left as is.
http://academic.evergreen.edu/projects/biophysics/technotes/program/2s_comp.htm