hary
Posts: 16
Joined: Wed Jan 18, 2017 8:17 am

RS232 communication

Mon May 29, 2017 3:37 pm

Hi

I have an instrument able to communicate data with RS232/USB adapter with ASCII character : (The almost same way as the AT command were used.)
http://www.optris.fr/telechargements-ac ... mmands.pdf

I'd like to be able to use it with my Pi.

What terminal emulator should I use and how should I use it ?

I 've tried many things even on a windows machine, but I can't get anything working.
I can't find the right information from google. It just leads me to a lot of confusion.

Any help would be appreciated.

Plus, if I can get this working, would it be possible to include this method of communication to retrieve data from the instrument with some Python or C code ?

User avatar
topguy
Posts: 5612
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: RS232 communication

Mon May 29, 2017 4:07 pm

The protocol of the OPTRIS CT is a binary protocol.
You cant use a terminal and just type the commands, you (almost) have to use a prorgramming language to send the correct bytes.
There are however (according to google) a couple of terminal programs that let you type and receive hexadesimal values. "Termite" and "Realterm" came up in my google attempt, but I think both are for Windows.
I dont know of any similar programs for Linux, but they probably exist.

User avatar
lmarmisa
Posts: 1223
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: RS232 communication

Mon May 29, 2017 4:19 pm

I am not sure if I understand your comment. I suppose that you are planning to connect your equipment to your RPi using an USB to serial adapter.

When you connect the USB adapter to your RPi, a new device will be created with name /dev/ttyUSB0.

Code: Select all

[email protected]:~ $ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 may 29 18:05 /dev/ttyUSB0
[email protected]:~ $
If you need a terminal emulator, you can use picocom:

Code: Select all

sudo apt-get install picocom

Code: Select all

[email protected]:~ $ picocom --h
picocom v1.7
Usage is: picocom [options] <tty device>
Options are:
  --<b>aud <baudrate>
  --<f>low s (=soft) | h (=hard) | n (=none)
  --<p>arity o (=odd) | e (=even) | n (=none)
  --<d>atabits 5 | 6 | 7 | 8
  --<e>scape <char>
  --e<c>ho
  --no<i>nit
  --no<r>eset
  --no<l>ock
  --<s>end-cmd <command>
  --recei<v>e-cmd <command>
  --imap <map> (input mappings)
  --omap <map> (output mappings)
  --emap <map> (local-echo mappings)
  --<h>elp
<map> is a comma-separated list of one or more of:
  crlf : map CR --> LF
  crcrlf : map CR --> CR + LF
  igncr : ignore CR
  lfcr : map LF --> CR
  lfcrlf : map LF --> CR + LF
  ignlf : ignore LF
  bsdel : map BS --> DEL
  delbs : map DEL --> BS
<?> indicates the equivalent short option.
Short options are prefixed by "-" instead of by "--".
[email protected]:~ $ 
If you wish to access to serial lines from python scripts, use the module pyserial.

http://pyserial.readthedocs.io/en/lates ... intro.html

hary
Posts: 16
Joined: Wed Jan 18, 2017 8:17 am

Re: RS232 communication

Tue May 30, 2017 7:53 am

Yes, I'm using an USB to serial adapter.
But I can't see it as ttyUSB0 or ACM0. I tried to plug in an Arduino and it appears as ACM0.
But still, my USB to serial adapter does not appear !

Plus I found this that is quite disturbing :
http://www.hobbytronics.co.uk/raspberry-pi-serial-port
I don't know if it has something to do with my problem ? These USB to serial adapter are quite confusing.
It seems the serial is the same as UART or RS232 ?

User avatar
lmarmisa
Posts: 1223
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: RS232 communication

Tue May 30, 2017 8:18 am

UART and RS232 signals have different electrical voltages. Take a look at this link:

https://electronics.stackexchange.com/q ... and-rs-232

RS232 (or other equivalent standard) can be avoid if the distance is very short. Usually UART to USB adaptors are not compatible with RS232 levels. They use logical TTL UART levels (5V or 3.3V and ground).

Ernst
Posts: 1179
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: RS232 communication

Tue May 30, 2017 8:40 am

There are quite a few hurdles to communicate with this device, one being the binary protocol and the other being the interface connection. I suspect that the RS232 cable attached to the device is intended into a PC (DTE) while the USB cable is intended to be plugged into a device (DCE). If this is correct you need to cross connect pins 2&3.

Code: Select all

Pin 2 --> Pin 3
Pin 3 --> Pin 2
Pin 5 --> Pin 5
This may be of use: http://www.optris.de/schnittstellen?fil ... ce-kit.pdf
The road to insanity is paved with static ip addresses

hary
Posts: 16
Joined: Wed Jan 18, 2017 8:17 am

Re: RS232 communication

Tue May 30, 2017 10:33 am

In fact I got this interface which look the same little PCB to add and a USB cable including the USB to serial converter.(When I plug only the cable in a windows PC it appears on COM3) (I can't see it on a linux machine, RaspberryPi nor Intel machine)

http://www.optris.de/schnittstellen?fil ... ctusbk.pdf

I got the interface and the instrument connected and talking to the windows10 computer thanks to the software provided, so I don't think some wire 2&3 need to be crossed.

User avatar
topguy
Posts: 5612
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: RS232 communication

Tue May 30, 2017 11:37 am

hary wrote:I can't see it on a linux machine, RaspberryPi nor Intel machine
Where have you been looking ?

1. Boot the Pi (or the other Linux machine)
2. Run the command "lsusb".
3. plug in the converter, run the commands "lsusb" and see if you have a new line.
4. then run the "dmesg" command and look at the last lines, it should tell you how the Linux kernel sees the usb device.

Hopefully you should have a new device in "/dev" named "ttyUSB0" or "ttyACM0" ( or "ttyACM1" if there is a ttyACM0 from before, check that )

hary
Posts: 16
Joined: Wed Jan 18, 2017 8:17 am

Re: RS232 communication

Tue May 30, 2017 1:07 pm

lsusb gives :
Bus 001 Device 006: ID 10c4:834b Cygnal Integrated Products, Inc.

dmesg gives :
[ 957.864061] usb 1-1.4: new full-speed USB device number 6 using dwc_otg
[ 957.971651] usb 1-1.4: New USB device found, idVendor=10c4, idProduct=834b
[ 957.971675] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 957.971689] usb 1-1.4: Product: Infrared Online Sensor Adapter
[ 957.971701] usb 1-1.4: Manufacturer: Silicon Labs
[ 957.971713] usb 1-1.4: SerialNumber: CT00015807

No more item (ttyUSB0 or ttyACM0 or other) appears in /dev (nor on the pi, nor on other linux intel machine)

Ernst
Posts: 1179
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: RS232 communication

Tue May 30, 2017 1:26 pm

Have you tried google to search for "idVendor=10c4, idProduct=834b" ?
This link most likely describes your problem: https://stackoverflow.com/questions/389 ... t-on-linux
The road to insanity is paved with static ip addresses

hary
Posts: 16
Joined: Wed Jan 18, 2017 8:17 am

Re: RS232 communication

Tue May 30, 2017 8:13 pm

Ernst wrote:Have you tried google to search for "idVendor=10c4, idProduct=834b" ?
This link most likely describes your problem: https://stackoverflow.com/questions/389 ... t-on-linux
It was it !
I reprogrammed the product_ID of the USB adapter cable and it now appears as ttyUSB0 on my intel linux machine ! (still need to check on my Pi, but I gess it should be ok)

Next step is to talk to the infrared thermometer with a terminal emulator and trough a python script or C code.

Thank you very much for your help.

mkol5222
Posts: 1
Joined: Thu Jun 06, 2019 3:04 pm

Re: RS232 communication

Thu Jun 06, 2019 3:13 pm

I took different path of learning cp210x driver about unusual VID:PID 10c4 834b
based on article https://unix.stackexchange.com/question ... n-embedded

a/ dmesg confirms my device
[4432162.907248] usb 2-2: New USB device found, idVendor=10c4, idProduct=834b
[4432162.907253] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[4432162.907256] usb 2-2: Product: Infrared Online Sensor Adapter
[4432162.907260] usb 2-2: Manufacturer: Silicon Labs

b/ load driver
sudo modprobe cp210x

c/ tell driver about my PID
sudo -s
echo 10c4 834b > /sys/bus/usb-serial/drivers/cp210x/new_id

d/ got device confirmed on ttyUSB0
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)

e/ binary protocol on it
screen /dev/ttyUSB0 115200

Hard work now starts to handle the protocol ;-)

Return to “Beginners”