304bl
Posts: 3
Joined: Mon Dec 16, 2013 3:01 am

how to interface my ttyUSB0 ?

Mon Dec 16, 2013 3:40 am

Hello everyone,

I'm posting here for some people help me or give me the way to take for what i want to do cause i have no idea how to proceed.
i explain :

i have my pi who is running a java server app( who handle sensor and relay), on side i have a java client app who connect by internet to the pi.
for prevent the case where there is no internet ou the init phase, i have to make my pi able to be connect by a usb cable to a pc or tablet and be recognize as a device for be able to let my client app connect via this serial (ttyUSB0) to my server app.
i hope i have been enough clear in what i am planning to do. (about the usb i have one wihout the vdd and the ground for prevent the fry risk)

how to set my pi for let be recognize as device when i will plug that usb cable ?

thanks for all who will take the time to help me ( and in case of someone start to say why use the usb and not the pin or serial blabla, cause in my project i NEED to )

kind regards

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: how to interface my ttyUSB0 ?

Mon Dec 16, 2013 8:33 am

There is a command called dmesg which reports useful information.

Plug the device in and then type dmesg at the command line.

What does dmesg report for your device?

304bl
Posts: 3
Joined: Mon Dec 16, 2013 3:01 am

Re: how to interface my ttyUSB0 ?

Tue Dec 17, 2013 1:13 am

dmesg ? i plug my pi to my pc with the usb cable and i should type dmesg to my pi ?

and what this command do ? can you explain me more please cause your answer confuse me.

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: how to interface my ttyUSB0 ?

Tue Dec 17, 2013 8:00 am

Hi,

I think you need the usb gadget API. Quite possibly the serial version.

It is covered in gagdet_serial.txt in the kernel documentation.

How well it is implemented on dwc_otg I do not know.

MF

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

Re: how to interface my ttyUSB0 ?

Tue Dec 17, 2013 9:51 am

304bl wrote:i have to make my pi able to be connect by a usb cable to a pc or tablet and be recognize as a device for be able to let my client app connect via this serial (ttyUSB0) to my server app.
i hope i have been enough clear in what i am planning to do. (about the usb i have one wihout the vdd and the ground for prevent the fry risk)
I'm not sure if its completely clear, but what i think your trying to do is to use a usb2serial-converter. The USB part is plugged into the PI and the serial is connected to the serialport on the PC.

Unplug the usb2serial, power on the Pi and log-on via ssh or open a terminal window.
- plug in the usb2serial.
- type "dmesg" in your terminal window.

At the end out the output you should see something like this.

Code: Select all

[1033597.574775] ftdi_sio 1-1.1:1.0: FTDI USB Serial Device converter detected
[1033597.574815] usb 1-1.1: Detected FT232BM
[1033597.574818] usb 1-1.1: Number of endpoints 2
[1033597.574822] usb 1-1.1: Endpoint 1 MaxPacketSize 64
[1033597.574826] usb 1-1.1: Endpoint 2 MaxPacketSize 64
[1033597.574829] usb 1-1.1: Setting MaxPacketSize 64
[1033597.575204] usb 1-1.1: FTDI USB Serial Device converter now attached to ttyUSB1
The last line tells you what name the device is using, and its ready to be used.

How to setup /dev/ttyUSB1 with correct baud-rates and how to send and receive data is another topic, but any linux serial howto should in theory work.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5198
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: how to interface my ttyUSB0 ?

Tue Dec 17, 2013 3:26 pm

topguy wrote:
304bl wrote:i have to make my pi able to be connect by a usb cable to a pc or tablet and be recognize as a device for be able to let my client app connect via this serial (ttyUSB0) to my server app.
i hope i have been enough clear in what i am planning to do. (about the usb i have one wihout the vdd and the ground for prevent the fry risk)
I'm not sure if its completely clear, but what i think your trying to do is to use a usb2serial-converter. The USB part is plugged into the PI and the serial is connected to the serialport on the PC.
...
Like @topguy, I'm not really sure about what you're trying to do. However, assuming you are trying to use a USB-to-serial(RS232)adapter is it something like this: http://www.cpmspectrepi.webspace.virgin ... apter.html? (If not can you post a link or picture of the device please).
In practice, it's usually the "serial-end" of the hardware that trickier to set-up than the (Pi's) software side since, until you have the hardware "wired up" correctly you don't know what software settings are needed. You may notice that part of the hardware shown in the above link includes a switchable "datalinker" that both provides LED indication of the serial links behaviour and the ability to change the physical configuration of the link, something I regard as an "essential tool" when working with RS232/serial systems. (FWIW, some, somewhat now "historical", RS232-related information can be found in one of my earliest webpages at: http://www.cpmspectrepi.webspace.virgin ... /rs232.htm ).
I normally use a basic "serial terminal emulator" for initial tests - GtkTerm (as shown in the first link) is the only one I found (so far) that provides "easy" support for USB-to-serial adapters (ie. /dev/ttyUSBn devices). That cannot be installed via "apt-get" but has to be downloaded and installed manually:
1) Download from: https://fedorahosted.org/gtkterm/
2) Install the required dependencies then build and install thus:

Code: Select all

sudo apt-get install libvte-dev intltool build-essential libgtk2.0-dev
gunzip gtkterm-0.99.7-rc1.tar.gz
tar -vxf gtkterm-0.99.7-rc1.tar
cd gtkterm-0.99.7-rc1/
./configure
make
sudo make install
H.T.H.,
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Return to “Interfacing (DSI, CSI, I2C, etc.)”