Send Data to com port

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
Post Reply
Pedromlo
Member
Posts: 12
Joined: Tue Sep 26, 2006 9:57 am
Location: Portugal

Send Data to com port

Post by Pedromlo »

Hi everyone,
I need to send some commands to the serial ports.
The thing is that the commands need to be constructed on VB code depending on variables configured on HB. So, i think the command association of the device with the hardware does not fit me.
Can anyone give me a clue or a piece of code on how to write data directly to one com port?

Thank you all
regards
Pedro
yaccri
HouseBot Special Member
Posts: 304
Joined: Wed May 07, 2003 2:19 pm
Location: Tel-Aviv, Israel
Contact:

Post by yaccri »

One way to do it is to:

- Use VBScript with GetPropertyValue for formatting
- Use VBScript with SetPropertyValue to set the property of a generic serial device with the fomatted message.
Pedromlo
Member
Posts: 12
Joined: Tue Sep 26, 2006 9:57 am
Location: Portugal

Post by Pedromlo »

Hi yaccri,
Thats the way to store the message, but what i need to know is how to send it. Is there some function like 'SendData' or so?
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

There are very few 'functions' in HouseBot. The functions in the scripting language are really just APIs to do very general things (like getting and setting property values) that you can do in the UI. For the most part, HouseBot doesn't bother the user with 'how' to do something (action/function), it just expects the user to tell 'what' the final state is. So as soon as you set a Property Value anywhere in the system (including a VB Script), the appropriate measures are taken to make that state change happen.

Check out this post. The user had a similar question.
Scott
Pedromlo
Member
Posts: 12
Joined: Tue Sep 26, 2006 9:57 am
Location: Portugal

Post by Pedromlo »

Thanks Scott,
I will try the instructions on the other post, and i will get there.
Pedromlo
Member
Posts: 12
Joined: Tue Sep 26, 2006 9:57 am
Location: Portugal

Post by Pedromlo »

Hi Scott,
If i construct a HEX string for example like '050002' and save it in a property value linked to a command on hardware like '%1%'.
Do you think this will work?
Or the string would be '502' and then the command would be '%x%'?
Or the string would be '502' and then the command would be '%1%' with DATA TYPE configured as HEX on command configuration?

Best Regards
ScottBot
Site Admin
Posts: 2790
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

It really depends on the equipment you are interfacing to. If you use %x%, it will take the data and parse it out as two character hex. It will send the numeric value and not the ASCII value.

So if you sent A0 using the %x% escape sequence, it would send 10100000

But if you sent it with %1%, it would send ASCII A(=0x41) and 0(=0x00) 0100000100000000

I think this is right... but it's been a while since I've been through the configuration on this, so I could be mistaken. I'd suggest consulting the equipment RS232 spec and just trying the different options.
Scott
Post Reply