Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Send / Receive ASCII string through serial port?
-
Is there anyway in Mango to send an ASCII string to a serial device and capture the response? I'm trying to connect to a RS-485 thermostat. A sample request for the set temperature of the thermostat would be:
"SN1 SH=?" and the reply would be "SN1 SH=68"
Thanks!
-
No, not currently. The number of possibilities that people might need from something like this are too vast to build a general data source. You would be much better off building a module in M2M2 specifically for your equipment.
-
Hi,
I tried workaround for this. I create simple JAR with openPort, closePort and sendData method with RxTx library.
This JAR I sent to jre/lib/ext folder with RxTx library.
Last step was create Meta data source point with some field with Cron timing.
In Javascript (Rhino) I wrote import of my JAR and called my methods.Now I am busy, but I want to create simple example and zip with my serial communicator classes.
It works.
Oja
-
Java script code for ASCII serial
importPackage(com.alarex.serialcommunicator); var serial = new SerialCommunicator(); var command = 'ati\r\n'; x = serial.openPort("/dev/ttyS0", 115200, 8, 1, SerialCommunicator.PARITY_NONE, SerialCommunicator.FLOWCONTROL_NONE); //sendDataAsString(String, timeout for response, timeout for last byte from response - detect packet end) vysledek = serial.sendDataAsString(command,1000,100); serial.closePort(); return vysledek;
You can call sendDataAsString multiple and return part1+","+part2+"," part3
and split in other fields in datasource. -
Copy SerialCommunicator.jar to ...jre/lib/ext . RxTx library have to be installed.
After copy you have to restart apache-tomcat.
I attached datapoint settings picture
Attachment: download link
-
OJA,
Thank you for the reply and example. I'll give it a try!
-
Oja,
The link to your files are removed or can not be found. Please let me know how I can get your code.
Thanks
Mo -
Ok, I am attaching it as one ZIP.
Attachment: download link