these are the write commands towards a serial port:
sendCommand(SendCOM3,"hallo\r\r") --- text format
sendCommand(SendCOM4,"\u0001\u0012\u0123\u000F\r\r") --- binary format
and works fine.
Now, who can tell me what I have to do to get the response message over the same serial port ?
Thanks
Ciao
marco
Since you're already writing to the port, I'm assuming you have the serial binding as an addon and the serial ports enabled.
Create a new item and bind it to the serial port to assign incoming data. For example,
String Hallo1 "Hallo [%s]" (hall0) {serial="SendCOM3"}
The data is a string that you'll need to parse. Restart OpenHAB, check the logs and you should see your item updated.
Add serial binding .jar file to your addons directory
org.openhab.binding.serial-1.7.1.jar
And add item to yourschema.items:
String MySerialDevice "MySerialDevice [%s]" { serial="/dev/ttyUSB0" }
change ttyUSB0 to your real tty serial device.
Related
The latest documentation for serial communication in Octave explains to use the "serialport" command to open the port instead of the deprecated "serial" command.
https://octave.sourceforge.io/instrument-control/overview.html
There is no explanation of how to close the serial port. I used this to successfully open the port and do some writing
s1=serialport('com5','Baudrate',57600)
num=write(s1,'help')
But I can't figure out how to close the port. I used this:
fclose(s1)
And got this error response
error: file id must be a file object, std::string, or integer value
Does anyone know how to close the serial port?
The octave functions attempt to mimic where possible the Matlan functions, which also does not have a close function.
To close the serial port, set the variable to something else, and if it is not used elsewhere, it will close the port.
# create a serialport references by the s1 variable
s1=serialport('com5','Baudrate',57600)
num=write(s1,'help')
# set s1 to something else
s1 = [];
# s1 was only variable referencing the serial port
# so the serial port is now freed/closed
You could also clear the variable:
clear s1
I am currently attempting to use a computer and RS232 connection to control a HP 34401A Multimeter. I am able to use commands such as "SYSTem:REMote" or "*TST" however when I attempt to use a command that sends back information nothing is returned to the computer. If I use another return command directly after I get a -410 error signifying that the output buffer is full. Are there any commands I need to use to tell it to send the information to the computer? I have been looking through the manual for one but cannot find it.
Extra Info:
RS232 Connection Setup: Baudrate=9600, Data bits=8, Stop bits=2, Parity=None
Since the connection is DTE to DTE I am using a null modem cable
I am using Termite to send commands to the multimeter
Thank you for any help!
So I have a grouping of "t commands", which is a string. These commands are supposed to be sent to a serial port, which will then run the command. I am using something similar to this in order to change the string into byte form which can then be read by the serial port:
(I'm using pySerial)
import serial
s=serial.Serial('COM')
str=('t command')
str=bytearray(str,"utf-8")
s.write.(str)
there are no errors, but the command is not working. Anybody have any ideas?
Just received my first ESP8266 wifi module with some excitement. However I've been unable to fully communicate with it. I have connected the module to my computer via a usb to serial cable and I'm power the module via a separate power supply (3.3v).
After powering the module up I receive the following information (via PuTTY or and Arduino serial monitor window):
[Vendor:www.ai-thinker.com Version:0.9.2.4]
ready
I have tried sending various AT commands e.g.
AT+RST
But I get no response. Using ctrl+m and ctrl+j in putty didn't help either.
Please see my youtube video if its helpful:
https://www.youtube.com/watch?v=RvasOuHuWDc
To get AT OK .
1.AT + PRESS ENTER + THEN CTRL +J WILL GIVE OK
2.Then Enter commands to execute
eg AT+GMR ->presss enter then ctrl+j
to get firmware
repeat step 1 for each command.
Make sure that you have putty or the Arduino serial console configured to send both a newline \n and a carriage return \r character. So AT+RST actually ends up being AT+RST\r\n. This took me a bit when I first received my ESP8266 modules. On the Arduino serial console this option is at the bottom of the window. I can see in your video you have it set to no line ending. Hopefully that does it for you.
I have many serial ports, but i want to select a particular one i.e /dev/ttyUSB0 to send and receive data, how to set port as /dev/ttyUSB0, i don't want user to select from a number of available ports, i just want to use /dev/USB0 only.
You can construct a serial port object using QSerialPort port("/dev/ttyUSB0"). This QSerialPort constructor accepts port name in the form it's present in QSerialPortInfo::portName(). It's not documented that this name is in the "/dev/ttyUSB0" form but it appears to be so.