How to view the DB9 to USB port??

More
07 May 2022 02:01 - 07 May 2022 02:05 #242197 by EdisonBin
Hi, phillc54
I used your method. After entering the terminal, the following appears
ttyS0
ttyS1
ttyS2
ttyS3
No matter unplugging or inserting the conversion cable, the ports in the terminal are these four, and they will not increase or decrease. Why? I can't find the port I want now
Last edit: 07 May 2022 02:05 by EdisonBin.

Please Log in or Create an account to join the conversation.

More
07 May 2022 03:55 #242201 by robertspark
Linux is not windows, it is not plug and play, the port won't appear or disappear when you plug the device in and out

you will need to try each one of those port addresses as given in your last post

Please Log in or Create an account to join the conversation.

More
07 May 2022 06:18 - 07 May 2022 06:29 #242207 by ALittleOffTheRails
Ok you have 4 serial ports on your machine.

Pick any one of ttyS0 - ttyS3.

The ports you have are "real" serial ports, ie: not USB > Serial ports.
These ports have been detected at boot, and wont change, unless you have some sort of special hot plug serial port card.

Now to have any kind of communication, you'll have to determine whether your USB -> Serial port cable have the pins wired as at the very least a null modem.

Some of the TLDP HOWTOs maybe a bit old, but the serial port is an older technology but still worthy. And is stilled used on embedded systems for debugor "hacking" with hardware

One way to test the operation of your Linux computer's serial port is
to try a loop back test, ie connect the RX & TX pins of one port to another.
This is a definite HOWTO for the serial port, well worth a read.
tldp.org/HOWTO/Serial-HOWTO.html

Loop back test.
amitasinghchauhan.medium.com/serial-port...ck-test-4a7e40da9055

Another thing to consider is one of the ports maybe claimed for a remote serial console.
www.iitk.ac.in/LDP/HOWTO/Remote-Serial-Console-HOWTO/index.html

Some info on serial port programming
tldp.org/HOWTO/Serial-Programming-HOWTO/
Last edit: 07 May 2022 06:29 by ALittleOffTheRails.

Please Log in or Create an account to join the conversation.

More
07 May 2022 07:11 #242212 by EdisonBin
HI,ALittleOffTheRails
I have read your answer carefully. That is to say, there are four serial ports on my computer: ttys0 - ttys3. It can't be used directly, can it? Do I need to configure it?
Is there a simpler way?

Please Log in or Create an account to join the conversation.

More
07 May 2022 07:33 #242216 by ALittleOffTheRails
I'm not too sure what you mean by "used directly".

How exactly do you want to use the serial port ?
Via your own python script using pyserial ?
Do you want to use it to connect as a serial console ?

The Links I provided should give you basically all the info you need.

As long as you open the serial port with "/dev/ttyS0" or whatever port you require. One thing you will have to ensure is that your linux user has access to the serial port. This will depend on the distro you are using. Again this concept should be explained in one of the links I gave.

Please Log in or Create an account to join the conversation.

More
07 May 2022 07:45 #242219 by EdisonBin
My ultimate goal is to enable my windows PC to communicate with Linux through this USB -- > RS232 line. So that they can send and accept hex bytes to each other.
But at present, I still have no communication success. Even if I use the serial port assistant software to send and receive, I don't receive bytes in each other's computere.

Please Log in or Create an account to join the conversation.

More
07 May 2022 09:18 #242221 by tommylight
lsusb
before and after inserting the usb.
The following user(s) said Thank You: EdisonBin

Please Log in or Create an account to join the conversation.

More
07 May 2022 09:52 - 07 May 2022 09:57 #242224 by ALittleOffTheRails
Like I said before, you should probably test the serial port on the Linux side via a "loop back test" just to be sure the Linux side can receive and transmit. I would also suggest to do this on the Windows side. Then I would try and establish communication out of the context of a Linuxcnc HAL component. Once you have established that you can communicate, then try it within the context of a HAL component.

Secondly are you sure that the USB>Serial RX connects to the TX on the Linux serial port. Conversely the USB>Serial TX needs to connect to RX on Linux serial port.

Also I implore you you study the links supplied. It's been a while since I've done any hardcore serial comms programming, and that was in purley x86 assembly under DOS, with the program directly configuring and read & writing to and from the comm chip.
Using pySerial should be magnitudes simpler.

Basically the stage you are at you really need to test both machines using a loop back test and confirm that the correct pins are connected.
Last edit: 07 May 2022 09:57 by ALittleOffTheRails.
The following user(s) said Thank You: EdisonBin

Please Log in or Create an account to join the conversation.

More
07 May 2022 20:49 #242252 by andypugh
One thing that we haven't yet sorted out.

Which PC is the USB plugged in to, and which the DB9?

You will only see things appear in /dev/tty if the USB is the Linux end. And even then, only if you have the right driver for the USB to serial chip.
The following user(s) said Thank You: EdisonBin

Please Log in or Create an account to join the conversation.

More
10 May 2022 02:51 #242456 by EdisonBin
Hi,Andy
The USB plug-in is a Windows PC, and the USB driver has been installed.
DB9 is plugged into a Linux PC.
Then I turned on the serial assistant on both computers. On windows, I selected the correct COM port. On Linux, I used the "dmesg | grep ttyS *" command to query that there are four ports, namely "ttyS0-ttyS3". Because I'm not sure which is the correct serial port, I tried it all.
But unfortunately, the communication failed
The two PCs did not receive the bytes sent to each other.

Please Log in or Create an account to join the conversation.

Time to create page: 0.087 seconds
Powered by Kunena Forum