I guess I am still doing something wrong. I have confirmed the data being sent by the microcontroller is correct, so I guess I am reading it wrong?
Here is some sample data sent by the microcontroller:
1 65 2 205 205 26 0 0
First is the TV on/off state, either 1 or 2.
Second is the name of the window talking, in this case "A", sent numerically so 65.
Third is whether the window is closed or open, 1 or 2.
Fourth is a light dependent resistor, 0 - 254
Five is another LDR, 0-254
Sixth is a temperature in Celcius, so roughly 0-100, more like 20-40
Seventh and Eighth are for the future, and right now are always zero.
There are spaces sent between each one.
So is this the correct way to read them?
- Code: Select all
wait for data from source connectionName to count 15
set eightBytes to read byte list from source connectionName to count 15
log "first byte = " & item 1 of eightBytes using type "Sample"
log "second byte = " & item 3 of eightBytes using type "Sample"
log "third byte = " & item 5 of eightBytes using type "Sample"
log "fourth byte = " & item 7 of eightBytes using type "Sample"
log "fifth byte = " & item 9 of eightBytes using type "Sample"
log "sixth byte = " & item 11 of eightBytes using type "Sample"
log "seventh byte = " & item 13 of eightBytes using type "Sample"
log "eighth byte = " & item 15 of eightBytes using type "Sample"
tell application "IndigoServer"
set value of variable "PTVOnOrOff" to item 1 of eightBytes
set value of variable "Pwloc" to item 3 of eightBytes
set value of variable "Pcoro" to item 5 of eightBytes
set value of variable "PLDR1d" to item 7 of eightBytes
set value of variable "PLDR2d" to item 9 of eightBytes
set value of variable "PTempd" to item 11 of eightBytes
set value of variable "PBlank1" to item 13 of eightBytes
set value of variable "PBlank2" to item 15 of eightBytes
end tell
Merry Christmas, and thanks for the help!
Brian