Send message by COM port

HouseBot Plugin Development Discussions.
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Send message by COM port

Post by beginner »

Help me please. I want develop plugin for new devices. Developers of these devices is the company 'Domintell'. I have the code that you want to send to this device by COM port.
Make it directly to my little program succeed. But how it make in HouseBot plugin, a don't know. Ie using Hardware Template and Plugin Template from SDK, all get done.
But as to declare the code, which must send to device by COM port - i don't know. Perhaps I did not quite understand the principle of work HardWare and Plugin. Please explain this to me.

.. and sorr for my english. I very little speek eng :)
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Send message by COM port

Post by ScottBot »

Before I go into detail on how you might want to develop your plugins, have you had a look a the Generic Serial plugin (Hardware Interface and Device) that will allow you to send and receive a wide range of data formats over the COM port?

If you have not investigated the Generic Serial plugin, I would suggest you look into it. It will be easier, since you do not need to develop anything.

If the Generic Serial plugin will not work for you, I can help by offering suggestions on how to design your plugins.
Scott
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Re: Send message by COM port

Post by beginner »

:?
Scott, thanks for you help...
I added Generic Serial device and Hardware. Device have two propertyes: power state and received data. I don't know what they need.
And also, i don't understand, how send and receive command in com port using Generic Serial plugin :oops:

Where i can read about it? Or Or tell me on the fingers, please. Maybe there is a ready example on this subject?
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: Send message by COM port

Post by ScottBot »

I know it's a bit confusing to get started with. I should do an online tutorial that covers it.

First, be sure to read through the online help for the Generic Serial hardware interface. It will describe how to setup the various serial commands and their associated data.

The next step is to create a custom Generic Serial Device Definition that matches the control abilities of the system you are interfacing to. You do this through the main menu (Settings / Configure Generic Serial Port Devices). After the Device has been defined, you can then create the Device in HouseBot and associate the commands in the Hardware Interface to the Property Values of the various Device Properties.

Most of this is documented in the online help for the Generic Serial Device, but it can be a bit hard to find. From the main menu, select Help / Plugin Help.... Then select Sample Serial Device Definition and view the online help.

As for assigning the property values to the commands, there is an online tutorial that does something similar for IR. If you are interested, check out the Controlling equipment with Infrared (IR) tutorial on the main website.
Scott
Richard Naninck
HouseBot Guru Extraordinaire
Posts: 1121
Joined: Tue Sep 28, 2004 7:49 am
Location: The Netherlands

Re: Send message by COM port

Post by Richard Naninck »

You can also check up on this post:

http://cebotics.com/forums/viewtopic.ph ... a&start=15
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Re: Send message by COM port

Post by beginner »

Thank you very much. Almost all happened!
But there is one problem ...

My device responds to the command until after the closure of COM port. Ie when I send the command using HouseBot (pressing button in client), my device responds only after I close HouseBot. I think in HouseBot need to config the COM port.

Example (on Visual Basic):

Code: Select all

Private Sub Command1_Click()
    Print #1, "TRP   626-1" 'It's worked ONLY after close port (Form_Unload)
End Sub

Private Sub Form_Load()
    Open "COM1" For Output As #1
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Close #1
End Sub
But this example worked very good:
(empty Form_Load and Form_Unload)

Code: Select all

Private Sub Command1_Click()
    Open "COM1" For Output As #1
    Print #1, "TRP   626-1"       'It's worked!
    Close #1           ' << Be sure!
End Sub

How to make HouseBot, to close the port after each command?
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Re: Send message by COM port

Post by beginner »

any ideas? :(
menesi
Member
Posts: 51
Joined: Fri Jan 05, 2007 4:48 pm
Location: Debrecen, Hungary, EU

Re: Send message by COM port

Post by menesi »

If you want to open and close COM port with script, then you didn't read posts of Scott & Richard certainly... As both of them write: try the Generic Serial Module.
Laszlo Menesi
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Re: Send message by COM port

Post by beginner »

Sorry, but I do not understand the relevance of scripts to Generic Serial Plugin. If you have an opportunity to forcibly close the port in Geniral Serial Port, after execution command, please tell me, how do it.

Thanks in advance!
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Re: Send message by COM port

Post by beginner »

If you look the other way? For example working with COM port, directly through its plug. Ie I want to develop a plugin device and hardware device, which will work with my device via COM port. Can someone explain the interaction itself COM port? How do I get \ send messages? Should I focus on Hardware and Device Template from SDK?
menesi
Member
Posts: 51
Joined: Fri Jan 05, 2007 4:48 pm
Location: Debrecen, Hungary, EU

Re: Send message by COM port

Post by menesi »

For example here is one of my serial stuffs, my DIY 6 zone irrigation system. This is a simple PIC controlled circuit with six 24V relay for valves in six zones, the serial communication controlled by PIC too. The protocol is very simple: sending "A" through COM port open 1st valve, sending "a" close it, sending "B" open the 2nd valve, etc. and there are commands for next valve, prev valve, open all, close all, status, etc. I control this irrigation system with HB too, without developing any plugin with hardware and device template from SDK. My steps were:

1. In "C:\Program Files\HouseBot\Config\GenericSerialDefs" I made 2 new files, a new .hdf file for hardware definition and a new .ddf file for device definition.
Example from .hdf, about the command defintion:

Code: Select all

<Commands>
         <Command NAME="Zone 1 On" Type="Ascii">
              <Send Data="A"/>
         </Command>
         <Command NAME="Zone 1 Off" Type="Ascii">
              <Send Data="a"/>
         </Command> 
         ...
</Commands>
Example from .ddf:

Code: Select all

<Properties NAME="Properties">
				<Property Default="No" Description="Zone1 Command" InitialValue="Off" NAME="Zone1 Command" Persistent="Yes" SameValueChanges="Yes" TraceToLog="No" Type="Alpha">
					<Values NAME="Values">
						<Value NAME="On"/>
						<Value NAME="Off"/>
					</Values>
				</Property> 
...
</Properties>
You can check these files in HB in Settings/Configure Generic Serial Port Devices menu.

2. The I made a new hardware interface in HB with selecting Generic Serial Module. In command configuration you can check the setting of .hdf file and the on-line help is very useful too.

3. Then I made the new hardware device in HB, using hardware interface in list, which is defined in step 2.

4. In new device there are properties: one "built-in" read only property "Received Data", and properties that you defined in steps 1. in .ddf file. At these properties I had to check the Command tab and I assigned the proper command.

5. At last I checked the settings of COM port at hardver interface in HB, then enabled it and so I could send commands with properties of new hardware device. The response arrived into the property "Received Data".

6. That's all...
Laszlo Menesi
beginner
Member
Posts: 9
Joined: Wed Nov 05, 2008 1:32 pm

Re: Send message by COM port

Post by beginner »

menesi why do you think that you have the port is closed immediately after sending command? :wink:

It can send, but the port would not be closed immediately. Your device can immediately respond to a message without closing the port. And my - could not.

Try to experiment ...
Use of MS Office VBA, or Visual Basic 6.

Open "COM1" for Output as # 1
Print # 1, "A"
'Close # 1' <<with out close!

If your device responds - for him to close the port after posting is not required.
menesi
Member
Posts: 51
Joined: Fri Jan 05, 2007 4:48 pm
Location: Debrecen, Hungary, EU

Re: Send message by COM port

Post by menesi »

I'm using this method (generic serial device + a script device to parse the received data) to communicate with my DSC alarm system with PC5401 card, with my DIY 8 zones, RS232 controlled irrigation system and now I'm developing the integration of my Buderus heating system with Buderus KM271 communication card. I have not problems with it, so I don't care what my serial ports are doing, open, close or anything... HB is working correctly, so it is right for me.
If I understand correctly what you write, you tried this HB method, you could send commands to your Domintell stuff, but after it you could see, that the Received Data property was empty. But if you restarted HB, the Received Data property contained the proper respond to your command. So you think, that your Domintell stuff can respond after port-closing-reopening. Is it right? If yes, it is very strange to me, as good as impossible...

Otherwise do you want communicate with Domintell DRS23201? http://www.domintell.com/menu_3.php?id=29 Where is its protocol?
Laszlo Menesi
DsA
Member
Posts: 7
Joined: Sun Nov 16, 2008 3:47 am

Re: Send message by COM port

Post by DsA »

Tell please how to listen to COM-port in Hardware Interface plugin. It does not have method Run which is for Device plugin.
And the second question. How to send the data on all devices from Hardware Interface plugin.
menesi
Member
Posts: 51
Joined: Fri Jan 05, 2007 4:48 pm
Location: Debrecen, Hungary, EU

Re: Send message by COM port

Post by menesi »

1st question:
In your device it has to be a property named Received Data. It automatically updates when data arrives from serial port. In my example this device is named to "DSC PC5401 Serial". There is an another device, which is a Script Device for parsing received data. The name of this device is "DSC PC5401 Parser". The connection of two devices (and the answer to your questions) is a task, named "DSC Parse". This task is very simple and executed when Received Data property is changed:

Code: Select all

If ('Security->DSC\DSC PC5401 Serial.Received Data' is Not Equal ' ' Then
Change 'Security->DSC\DSC PC5401 Parser.State' to 'Running'
(The "Security->DSC\" tags are the part of my grouping settings.) So, incoming datas are in property Received Data in serial device --> this event executes the task --> this task executes the parser script --> this script does anything what you want...

2nd question:
I don't understand exactly your problem, please write it exactly a little.
Laszlo Menesi
Post Reply