Send ASCII to Serial Device

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Send ASCII to Serial Device

Post by incoronado »

I need to send the string ,?0800%1% as an ASCII using the Serial Plugin. It looks to me as though the device doesn't like the ASCII "?". I can send it as HEX if translate the ASCII to Hex, buI don't know how to send a 2 byte variable (i.e., "03") using %x% when sending as Hex. Any help would be appreciated.
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

I have sent ASCII strings containing a ? lots of times. You will see a problem while sending an ASCII &. This is an outstanding BUG that will hopefully be addressed very very soon by the Meedio team!!



I also send ASCII strings like: !1MVL%1% and that also works fine.

Maybe you can start a trace to see what your true output from the serial device is, or connect another PC with a hyperterm to your HBServer to see what is received. That will usually give you some good clues about the problem!
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Post by incoronado »

Good call. I never set up a trace before and it worked great. It looks like my problem is that my property value sends [0-15] decimal to the serial device. How would I send an ASCII command that represents a two digit HEX value [00-0F] embedded in my command? I'm using a slider control with a range of values from 0-15 decimal.
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Post by Richard Naninck »

You could run a vbscript (script device) triggered by a task that tracks your slider movement. So if the slider is moved, the script will run. The script could then do a simple decimal to hex conversion and set the property from there.



Another option is to create 16 entries in your propertie and link these 16 entries to your hardware device. So the device would hold commands like ,?080000 up to ,?08000F and these will be linked to device.property, 0 - 15.



Create a property and populate it with 16 labels. Could be 0, 1, 2, .... 15 or whatever. Then link 0 to ,?080000 ..... , 15 to ,?08000F



Hope this makes sense to. It will work, just not sure how to explain it better.
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Post by incoronado »

I like the VB Script idea. Haven't done VB/HB before, but I think it is within the range of my abilities. I might run into this again since my serial device uses hex for just about everything. I did think about creating 15 commands in my serial device and mapping them to property values. Either way thanks much for the input.
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

incoronado wrote:How would I send an ASCII command that represents a two digit HEX value [00-0F] embedded in my command?
Have you tried using %x% instead of %1% in the Write Data string?
Scott
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Post by incoronado »

Value = 7



,?0800%x% and writes:



Writing [8] bytes [2c 3f 30 38 30 30 07 0d]



,?0800%1% and writes:



Writing [8] bytes [2c 3f 30 38 30 30 37 0d]



Needs to be:



Writing [9] bytes [2c 3f 30 38 30 30 30 37 0d]
incoronado
Senior Member
Posts: 153
Joined: Fri Mar 19, 2004 12:30 am
Location: San Diego, CA

Post by incoronado »

I just found this. This exact issue was addressed by MediaStorm



http://www.meedio.com/forum/about15177-0-asc-15.html



he asks



While we're on the topic of HEX, how about a checkbox or something to allow for padding HEX values? This should be very simple..



With padding enabled anything single digit (byte) would be zero padded to 2-bytes length.



IE- 0-15 would be padded as 00 - 0F



This would take care of the bulk padding need for lots of different devices and shouldn't be much to implement at all.
Post Reply