Catch incoming data in variable

A plugin that allows for end user development of multiple RS232 device control systems.
User avatar
hakha4
Member
Member
Posts: 88
Joined: Wed Dec 24, 2008 3:18 am
Location: Moholm Sweden
Contact:

Catch incoming data in variable

Postby hakha4 » Mon Oct 04, 2010 11:57 am

Hi!
I've restarted with MLServer/Mainlobby and want to use it for checking different variables from my pool etc and show it in MainLobby. I have a control system with microprocessors (ZX1280). From this I can send/recieve data serial. The system collect's temp's,pH etc. Does MLGeneric expose incoming data in a variable ? I just want to catch the incoming string for evaluation in a script. I haven't find much technical info about the plugin.
Any help would be appreciated
Regards Håkan

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Re: Catch incoming data in variable

Postby ricks » Tue Oct 05, 2010 11:27 am

Hello,

I use MLGenericDevice quit a bit. Do you have a document from the device which shows you 1) whether it communicates via ascii or hex and 2) what the data actually looks like when it is received? MLGenericDevice only handles ascii but there is another plugin which will handle both although I have never used it so can't help you there.

MLGenericDevice will allow you to create ML commands to talk to the device as well as a section which will allow you to format the response: set variable names and run other ML commands or scripts.

If you don't have docs you could use something like Advanced Serial Port Monitor (http://www.aggsoft.com/) to look at the data while it's active to get a sense of what the data looks like.

Rick

User avatar
hakha4
Member
Member
Posts: 88
Joined: Wed Dec 24, 2008 3:18 am
Location: Moholm Sweden
Contact:

Re: Catch incoming data in variable

Postby hakha4 » Tue Oct 05, 2010 2:56 pm

Hi Rick and thank's for reply. The device I want to communicate with MLGeneric serial is 'homebrowed' and I send ASCCI. I can send test strings from this and in debug mode I se the string as expected in plugin. But my main issue is how to get this string into a variable for further proccessing (script maybe). The device sends info from microprocessor via a prefix and then actual data or status information etc ex for temperatures, t1 27.35,t2 22.56 for relay's r1_on/r1_off etc. What command to use for storing the incoming string (varies length,delimiter chr13)? I can do this in VB but I want to use the flexibility in MLServer. If one uses a fixed command set I realize that MLServCmd for every item is ok but I need to evaluate the incoming data in a more complex form. Any help appreciated
Regards Håkan

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Re: Catch incoming data in variable

Postby ricks » Tue Oct 05, 2010 4:41 pm

I've included a few pics, hopefully they may help. And hopefully I understand what you're asking. :wink:

Pic 1 shows the setup page. The key here, highlighted in red, is the terminator. Once you've set up the port info, you can then go to the debug tab and see the response coming back from the device. This may help with the proper terminator.

Pic 2 shows the command tab. In this case I need to send a request to the device to get a status. Example is to show me the bass level of the music in the dining room or Z1.

Pic 3 shows the device response setup. When the plugin sees the characters entered in the device response box, in this case ?1BS<<VAR>>+, it will then set the ML variable {{audio_dining_bass}} to the value within the <<VAR>> or 14. From there you can have MLS perform actions if you like. For example, you can create a macro like "If the temp drops below 20 degrees, send me a text message".

In your case, you may be able to set the device response to T1<<VAR>> and set another device response to T2<<VAR>> and if you set the Variable Name to Temperature_1 and Temperature_2, then you should get ml server variables of {{temperature_1}} with a value of 27.35 and {{temperature_2}} with a value of 22.56.

The characters surrounding the <<VAR>> need to be consistent and the more consistent characters you can add to the device response box, the more accurate it will be. For example, if the response includes the coma as in t1 27.35, then setting the device response box to be t1<<VAR>>, may work better.

Clear as mud, right?
You do not have the required permissions to view the files attached to this post.

User avatar
hakha4
Member
Member
Posts: 88
Joined: Wed Dec 24, 2008 3:18 am
Location: Moholm Sweden
Contact:

Re: Catch incoming data in variable

Postby hakha4 » Tue Oct 05, 2010 6:23 pm

Hi again!
Crystal clear! I've been struggling with MLGenericSerial not aware of MLGenericDevice ! Downloaded MLGD and with your clear instructions hooked up in a minute and it works like a charm.
Thanks alot
Regards Håkan

User avatar
DaveB
Simply Incredible
Simply Incredible
Posts: 3143
Joined: Sun May 30, 2004 10:57 pm
Location: Mays Landing, NJ
Contact:

Re: Catch incoming data in variable

Postby DaveB » Tue Oct 05, 2010 8:26 pm

Rick - Nice job on this one!
Thanks!

Dave Bruner
:shock:

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Re: Catch incoming data in variable

Postby ricks » Tue Oct 05, 2010 8:29 pm

Sorry. Missed the MLGenericSerial v. MLGenericDevice. I'm not sure the serial plugin has been discussed for years so I didn't make the connection. Although Generic Serial is free (great price), I too found it too flakey and outdated although I do think I have it running an old hex security cam box. :oops:

Rick

User avatar
DavidL
Simply Incredible
Simply Incredible
Posts: 11071
Joined: Sat Feb 08, 2003 9:39 am
Location: Metamora, Michigan
Contact:

Re: Catch incoming data in variable

Postby DavidL » Wed Oct 06, 2010 6:34 am

There is also the MLComDevice which is the latest serial device driver. Supports Hex as well.


Return to “MLGenericDevice”

Who is online

Users browsing this forum: No registered users and 1 guest