LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Weight scale and Linux (https://www.linuxquestions.org/questions/linux-hardware-18/weight-scale-and-linux-4175614749/)

random_n 09-29-2017 12:53 PM

Weight scale and Linux
 
Hello, new to the forums and hopefully can get some expert advice!
I am trying to setup a digital scale with the RS-232 interface. it is connected to COM3.
I need to communicate with the scale at 9600, n, 8, 1, which I think is default (or do I need to set the COM port in Linux first?)

In Windows, I send the P character over Hyperterminal to the COM3 port and the scale responds with the weight (something like 5.00LBS.)

I am trying to see if I can get the same scenario in Linux (Ubuntu)
I opened 2 temrinals, I execute ""cp /dev/ttyS2 /dev/tty" in terminal1.
From terminal2 I exexute "echo P >/dev/ttyS2'
Expected output: get the scale to respond with the weight
Actual output in terminal2: no output
I believe I am missing something.

The commands were taken from http://www.tldp.org/HOWTO/Serial-HOWTO-10.html

TB0ne 09-29-2017 01:33 PM

Quote:

Originally Posted by random_n (Post 5764483)
Hello, new to the forums and hopefully can get some expert advice!
I am trying to setup a digital scale with the RS-232 interface. it is connected to COM3.
I need to communicate with the scale at 9600, n, 8, 1, which I think is default (or do I need to set the COM port in Linux first?)

In Windows, I send the P character over Hyperterminal to the COM3 port and the scale responds with the weight (something like 5.00LBS.)

I am trying to see if I can get the same scenario in Linux (Ubuntu)
I opened 2 temrinals, I execute ""cp /dev/ttyS2 /dev/tty" in terminal1.
From terminal2 I exexute "echo P >/dev/ttyS2'
Expected output: get the scale to respond with the weight
Actual output in terminal2: no output I believe I am missing something.

The commands were taken from http://www.tldp.org/HOWTO/Serial-HOWTO-10.html

A few things jump out:
  • Why are you copying /dev/ttys2 to /dev/tty??? What's the purpose of that, since...
  • ...your next command does nothing with /dev/tty??
  • How do you know what serial port you're using
And how are you plugging in to the scale? USB? Most computers these days don't even HAVE a serial port, but USB to serial devices work fine. They are typically /dev/ttyUSB0, etc. As to whether you need to set the baud first...we don't know. You don't tell us anything about your hardware, or the version/distro of Linux you're using.

You can try to load a program called minicom (like hyperterm), but we can't tell you how, since you don't tell us what Linux you're using, and set baud/etc., from there.

random_n 09-29-2017 02:27 PM

Quote:

Originally Posted by TB0ne (Post 5764501)
A few things jump out:
  • Why are you copying /dev/ttys2 to /dev/tty??? What's the purpose of that, since...
  • ...your next command does nothing with /dev/tty??
  • How do you know what serial port you're using
And how are you plugging in to the scale? USB? Most computers these days don't even HAVE a serial port, but USB to serial devices work fine. They are typically /dev/ttyUSB0, etc. As to whether you need to set the baud first...we don't know. You don't tell us anything about your hardware, or the version/distro of Linux you're using.

You can try to load a program called minicom (like hyperterm), but we can't tell you how, since you don't tell us what Linux you're using, and set baud/etc., from there.

Thank you for the response.
Regarding why am I copying- I followed an example from the link I originally provided. If I need to listen to the COM port somehow different- please explain how.
Regarding the COM port I run "dmesg | grep tty" and confirm the ports
Regarding how I am plugging in the scale- true serial port. Both the scale and the system have the RS-232.
OS: I am using Ubuntu 16.04.3 LTS.
system platform - the system is based off Intel Bay Trail J1900

More on this:
I connected the cable (to ensure my COM are working under Linux) to another system and executed "cat /dev/ttyS0" (COM1) . I then sent "echo "Hello" > /dev/ttyS2" (COM3)
I did receive the message, then I tried sending the message from ttyS0 to ttyS2 and it is OK.
Still cannot get the response from the scale.

jefro 09-29-2017 02:43 PM

Some ideas here. https://www.cyberciti.biz/hardware/5...erial-console/

Many of the industrial scales offer support for embedded OS's like QNX and others. Be sure to look at any documentation the OEM may offer.

random_n 09-29-2017 03:16 PM

Quote:

Originally Posted by jefro (Post 5764528)
Some ideas here. https://www.cyberciti.biz/hardware/5...erial-console/

Many of the industrial scales offer support for embedded OS's like QNX and others. Be sure to look at any documentation the OEM may offer.


Thank you! I used Putty and it worked after I set the Baud rate to 9600, 8, n, 1

jefro 09-29-2017 08:21 PM

Thanks for the update and solution.


All times are GMT -5. The time now is 09:20 AM.