View unanswered posts | View active topics It is currently Sun May 19, 2013 10:02 am



Reply to topic  [ 8 posts ] 
 Serial Bridge and unicode 
Author Message

Joined: May 15, 2003
Posts: 5
Location: Maryland
Post Serial Bridge and unicode
I have been using serial bridge (1.0.9) under 10.4.11 but when I upgraded to 10.5.8 my AppleScript broke. It has been suggested that the issue was the AppleScript change to 4 byte unicode. Here is a portion of my script

tell application "Serial Bridge"
send to source "test" string "D"
set restOfString to read string from source "test"
log restOfString using type "Sample"
end tell


set AppleScript's text item delimiters to ASCII character 10 <---- I think the problem is here, did Applescript change?
set theList to every text item in restOfString <---- it does not seem to create a list
set AppleScript's text item delimiters to ","
set listLength to count of theList <---- listLength ends up being 1

Does anyone know if this could be the unicode vs traditional ASCII change and if so how do I address it?


Tue Dec 22, 2009 12:29 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11682
Location: Texas
Post Re: Serial Bridge and unicode
I'm not sure. Turn on the logging in Serial Bridge so that it writes to the Event Log every incoming byte. What is shown?

Does it work if you set the delimiter to CR (13) instead of LF (10)?

_________________
Image


Fri Jan 01, 2010 1:01 pm
Profile WWW

Joined: May 15, 2003
Posts: 5
Location: Maryland
Post 
Here is a sample (same as it has always been)
Jan 1, 2010 2:10:56 PM
Sent 44
Sample 289058C800000021 00,24.00,75.12
281860C8000000D0 00,21.93,71.40
28A477C400000095 00,33.18,91.62
28E4A5B9010000A3 00,12.31,54.12
28FC6DC8000000C9 00,17.93,64.21
283237C80000006D 00,41.00,105.68
28169A5B0100001A 00,20.12,68.15
28D67AB901000011 00,35.87,96.46
282E38BA01000020 00,12.87,55.12
2841B65B01000068 00,21.93,71.40
2861C45B01000030 00,21.25,70.18
281134C8000000CC 00,16.87,62.31
2891B55B010000E2 00,23.06,73.43
28394BC8000000D9 00,18.12,64.56
2865AC5B010000C3 00,22.81,73.00
28554BC800000067 00,15.81,60.40
28F5A9B9010000EE 00,13.12,55.59
28F5A5B9010000CF 00,38.43,101.06
28AD78C80000007E 00,20.68,69.18
288B68C800000006 00,20.00,67.93
28AB32C800000098 00,21.68,70.96
28C73BC8000000D5 00,16.37,61.43
2897DA5B0100002E 00,23.37,74.00
286F60C4000000DF 00,21.37,70.40
260EBB8000000094 19,6.56,43.78,83
26FB8F8000000096 19,22.25,71.96,28
EOD

I tried the 13 character with no change


Fri Jan 01, 2010 1:12 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11682
Location: Texas
Post 
That is with the logging checkbox enabled in Serial Bridge? That doesn't look like Serial Bridge's normal logging output for incoming data...

_________________
Image


Fri Jan 01, 2010 1:15 pm
Profile WWW

Joined: May 15, 2003
Posts: 5
Location: Maryland
Post 
I cleared the window and let it do one query and get this;

Jan 1, 2010 2:13:56 PM
Sent 44
Sample 289058C800000021 00,24.00,75.12
281860C8000000D0 00,22.00,71.53
28A477C400000095 00,33.06,91.40
28E4A5B9010000A3 00,12.56,54.56
28FC6DC8000000C9 00,18.06,64.46
283237C80000006D 00,40.50,104.78
28169A5B0100001A 00,20.31,68.50
28D67AB901000011 00,35.62,96.00
282E38BA01000020 00,13.31,55.90
2841B65B01000068 00,21.93,71.40
2861C45B01000030 00,21.25,70.18
281134C8000000CC 00,16.87,62.31
2891B55B010000E2 00,23.06,73.43
28394BC8000000D9 00,18.12,64.56
2865AC5B010000C3 00,22.81,73.00
28554BC800000067 00,15.87,60.53
28F5A9B9010000EE 00,13.37,56.03
28F5A5B9010000CF 00,38.18,100.62
28AD78C80000007E 00,20.68,69.18
288B68C800000006 00,20.06,68.06
28AB32C800000098 00,21.62,70.84
28C73BC8000000D5 00,16.43,61.53
2897DA5B0100002E 00,23.37,74.00
286F60C4000000DF 00,21.37,70.40
260EBB8000000094 19,6.59,43.84,83
26FB8F8000000096 19,22.31,72.09,28
EOD


Received 32 38 39 30 35 38 43 38 30 30 30 30 30 30 32 31
Received 20 30 30 2C 32 34 2E 30 30 2C 37 35 2E 31 32 0D
Received 0A 32 38 31 38 36 30 43 38 30 30 30 30 30 30 44
Received 30 20 30 30 2C 32 31 2E 39 33 2C 37 31 2E 34 30
Received 0D 0A 32 38 41 34 37 37 43 34 30 30 30 30 30 30
Received 39 35 20 30 30 2C 33 33 2E 30 36 2C 39 31 2E 34 30 0D 0A 32 38 45 34 41 35 42 39 30 31 30 30 30 30 41 33 20 30 30 2C 31 32 2E 36 32 2C 35 34 2E 36 38 0D 0A 32 38 46 43 36 44 43 38 30 30 30 30 30 30 43 39 20 30 30 2C 31 38 2E 31 32 2C 36 34
Received 2E 35 36 0D 0A 32 38 33 32 33 37 43 38 30 30 30
Received 30 30 30 36 44 20 30 30 2C 34 30 2E 35 30 2C 31
Received 30 34 2E 37 38 0D 0A 32 38 31 36 39 41 35 42 30
Received 31 30 30 30 30 31 41 20 30 30 2C 32 30 2E 34 33
Received 2C 36 38 2E 37 31 0D 0A 32 38 44 36 37 41 42 39 30 31 30 30 30 30 31 31 20 30 30 2C 33 35 2E 35 30 2C 39 35 2E 37 38 0D 0A 32 38 32 45 33 38 42 41 30 31 30 30 30 30 32 30 20 30 30 2C 31 33 2E 35 30 2C 35 36 2E 32 35 0D 0A 32 38 34 31 42 36
Received 35 42 30 31 30 30 30 30 36 38 20 30 30 2C 32 31
Received 2E 39 33 2C 37 31 2E 34 30 0D 0A 32 38 36 31 43
Received 34 35 42 30 31 30 30 30 30 33 30 20 30 30 2C 32
Received 31 2E 31 38 2C 37 30 2E 30 36 0D 0A 32 38 31 31 33 34 43 38 30 30 30 30 30 30 43 43 20 30 30 2C
Received 31 36 2E 39 33 2C 36 32 2E 34 33 0D 0A 32 38 39 31 42 35 35 42 30 31 30 30 30 30 45 32 20 30 30 2C 32 33 2E 31 32 2C 37 33 2E 35 36 0D 0A 32 38 33 39 34 42 43 38 30 30 30 30 30 30 44 39 20 30 30 2C 31 38 2E 30 36 2C 36 34 2E 34 36 0D 0A 32 38 36 35 41 43 35 42 30 31 30 30 30 30 43 33 20 30 30 2C 32 32 2E 37 35 2C 37 32 2E 38 37 0D 0A 32 38 35 35 34 42 43 38 30 30 30 30 30 30 36 37 20 30 30 2C 31 35 2E 39 33 2C 36 30 2E 36 32 0D 0A 32 38 46 35 41 39 42 39 30 31 30 30 30 30 45 45 20 30 30 2C 31 33 2E 35 30 2C 35 36 2E 32 35 0D 0A 32 38 46 35 41 35 42 39 30 31 30 30 30 30 43 46 20 30 30 2C 33 38 2E 30 36 2C 31 30 30 2E 34 30 0D 0A 32 38 41 44 37 38 43 38 30 30 30 30 30 30 37 45 20 30 30 2C 32 30 2E 36 38 2C 36 39
Received 2E 31 38 0D 0A 32 38 38 42 36 38 43 38 30 30 30 30 30 30 30 36 20 30 30 2C 31 39 2E 38 31 2C 36
Received 37 2E 35 39 0D 0A 32 38 41 42 33 32 43 38 30 30
Received 30 30 30 30 39 38 20 30 30 2C 32 31 2E 38 37 2C 37 31 2E 33 31 0D 0A 32 38 43 37 33 42 43 38 30
Received 30 30 30 30 30 44 35 20 30 30 2C 31 36 2E 35 30 2C 36 31 2E 36 35 0D 0A 32 38 39 37 44 41 35 42 30 31 30 30 30 30 32 45 20 30 30 2C 32 33 2E 34 33 2C 37 34 2E 31 32 0D 0A 32 38 36 46 36 30 43 34 30 30 30 30 30 30 44 46 20 30 30 2C 32 31 2E 33 37 2C 37 30 2E 34 30 0D 0A 32 36 30 45 42 42 38 30 30 30 30 30 30 30 39 34 20 31 39 2C 36 2E 37 38 2C 34 34 2E 31 38 2C 38 32 0D 0A 32 36 46 42 38 46 38 30 30 30 30 30 30 30 39 36 20 31 39 2C 32 32 2E 32 35 2C 37 31 2E 39 36 2C 32 38 0D 0A 45 4F 44 0D 0A 0D 0A

Jan 1, 2010 2:14:11 PM
Closing Connection "test"


Fri Jan 01, 2010 1:19 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11682
Location: Texas
Post 
Post the rest of your Serial Bridge script. I need more details on what your script is trying to do with the data.

_________________
Image


Fri Jan 01, 2010 4:15 pm
Profile WWW

Joined: May 15, 2003
Posts: 5
Location: Maryland
Post 
Here is the entire script;

I am pretty sure the issue is the difference between 10.4 and 10.5 as another source pointed out;
You may be running up against the change to 4 byte unicode text in applescript. I dont know how serial bridge handles this, but if it's passing unconverted single byte, traditional ascii up the pipe to you then you may not be able to compare it against strings you create in AppleScript like "ascii character 10" without converting something somewhere.

Basically I query a 1-wire device and get back a block of data that includes the id and temp in C and F plus humidity if it is there. I then parse through the list to assign the proper temp to the proper field. has worked for years as written but broke when I upgraded to 10.5 so now I get no temp readings.
Code: Select all
write log "----------Quick Query Start-----------" as string
remove unit events "quick query THLinc"
--execute script "quick query THLinc" in 1 * minutes
set TempCheckSum to 0

tell application "Serial Bridge"
   send to source "test" string "D"
   set restOfString to read string from source "test"
   log restOfString using type "Sample"
end tell


set AppleScript's text item delimiters to ASCII character 10
set theList to every text item in restOfString


set AppleScript's text item delimiters to ","
set listLength to count of theList

repeat with i from 1 to listLength
   set theItems to every text item in item i of theList
   
   if item 1 of theItems is "283237C80000006D 00" then
      set value of "Temp - Tank 2 Top" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28E4A5B9010000A3 00" then
      set value of "Temp - Ground Leaving HxC" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "282E38BA01000020 00" then
      set value of "Temp - Solar Leaving Array" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "287366C400000065 00" then
      set value of "Temp - Ground Leaving Loop" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28A477C400000095 00" then
      set value of "Temp - Load Leaving HP/Boiler" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28F5A5B9010000CF 00" then
      set value of "Temp - Tank 1 Bottom" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28D67AB901000011 00" then
      set value of "Temp - Load Entering HP" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28F5A9B9010000EE 00" then
      set value of "Temp - Ground Leaving Heatpump" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28554BC800000067 00" then
      if (status of "Relay - AHU 2") is true then
         set value of "Temp - AHU 2 Supply Air" to (item 3 of theItems as number) - 0.01
      else
         set value of "Temp - AHU 2 Supply Air" to 0
      end if
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "2865AC5B010000C3 00" then
      set value of "Temp - AHU 1 Supply Water" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "28394BC8000000D9 00" then
      set value of "Temp - DW Entering HxC" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
   if item 1 of theItems is "2861C45B01000030 00" then
      set value of "Temp - DW Leaving HxC" to (item 3 of theItems as number) - 0.01
      set TempCheckSum to TempCheckSum + 1
   end if
   
end repeat


set AppleScript's text item delimiters to ""

if (TempCheckSum) is less than 12 then
   write log " Warning .... Warning.... " & 12 - TempCheckSum & " Sensor(s) not updating"
   beep
end if
set value of "Temp - Load Delta T" to ((value of "Temp - Load Leaving HP/Boiler") - (value of "Temp - Load Entering HP"))

write log "----------Quick Query End-----------" as string


Fri Jan 01, 2010 4:26 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11682
Location: Texas
Post 
wnbrandt wrote:I am pretty sure the issue is the difference between 10.4 and 10.5 as another source pointed out;

What is the other source? Is it another forum thread? If so, please link to it so I can see the background information.

I tried the following standalone script which correctly returned a list with 3 items:
Code: Select all
set myFunString to "hello there" & (ASCII character 13) & (ASCII character 10) & "asdf asdf" & (ASCII character 13) & (ASCII character 10) & "qwer qwer"

set AppleScript's text item delimiters to ASCII character 10
set theList to every text item in myFunString

You can try coercing restOfString into Unicode text, but I'm not sure if that is the problem or not:
Code: Select all
tell application "Serial Bridge"
   send to source "test" string "D"
   set restOfString to read string from source "test"
   log restOfString using type "Sample"
   set restOfString to restOfString as Unicode text
end tell

_________________
Image


Sat Jan 02, 2010 11:21 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.