How to connect to USB TTY from BeagleBone Black? - python

I would like to establish serial communication from a Windows PC to the BeagleBone Black. The purpose is to have a Python application on the BeagleBone interact with a terminal running on the PC. I would like to use the same USB cable I use for the SSH connection (from PC to micro-usb on the BB), but instead of SSH, I want to open a serial connection via something like TeraTerm, and have a running python application connect to the TTY, something like /dev/ttyUSB. However, this TTY does not exist.
Note that I'm not trying to do serial debugging, as this article suggests. I'm also not trying to do this connection over UART. I specifically want to communicate with a python application via a terminal running on the PC. The Python application would use a library like pyserial.
Since the TTY is not showing on the BeagleBone, how can I proceed?

A TTL to USB converter will work. I got an older model that is still produced from some company. Here is one I found easily online at Adafruit: https://www.adafruit.com/product/954.
That will give you TX, RX, GND, and PWR. Please make sure to get a 3.3v type if you are using it for the BBB.
Here is some write up w/ questions/answers: https://askubuntu.com/questions/40959/how-do-i-connect-to-tty-com-dev-ttyusb0
Sometimes when you use PuTTY w/ Win 10 COM ports, it is necessary to make sure you get the COM port correct. Actually, every time! Click on the connection ICON on the bottom, right of the screen under the "^", click on the Open Devices and Printers, and then go to the BBB on the photo screen. Once you right click and go to Properties, finally click on the Hardware tab to find your COM Port. Then, one can use a COM Port on Win 10 w/ the BBB along w/ PuTTY.
So, w/ PuTTY, you can click the serial connection, type your COM Port (COM6 or whatever), and finally click Open.
...

Related

Is there a way to quit an app when a certain device is physically connected/disconnected to my MacBook?

I have a MacBook and a Thunderbolt hub. There's an app called "BetterDummy" for enabling Hi-DPI when connected to display via the hub. I always open it when I connect the hub. However, I don't want it to be still open after I disconnect it.
Out of curiosity, is there any way that I could detect if devices are connected to the system? What I want is to open the app when connected to the hub, while quitting it if I disconnect the hub. It will be great if this can be coded in Python, but any will do! Thanks for any help!
What I have researched
Many articles are talking about searching devices in the network, but I want to search for physically connected devices. Maybe like a "service" that can detect it in the background (I put a quote here because I'm not familiar with the term service. my understanding of service is something that runs based on system events in the background)
There's something called system_profiler on mac that can list all the USB devices connected, but again, I want it to do "automatically" (e.g. check it every x seconds, if disconnected, quit the app).
I didn't see any related actions in Apple's Shortcuts app.

Using Yun bridge library on Raspberry pi

I am new here and this is my first post. I am not 100% sure where to post this. I think it is something on the OS level so I chose to post it here. Moderators please move it to the correct place if it does not belong here.
I am developing a controller to control a industrial type process. I started off using the Arduino Yun that is a all in one type board with a Linux processor and Arduino controller on one board (if you dont know that already). It uses what they call the Bridge to communicate between the 2. Basically it talks over the com port and you don't have to build your own protocol, it does it for you.
Now the Yun is turning out to be to low specked for what I want to do so now I want to use a Raspberry Pi and hookup an Arduino Mega to do all the low level sensor stuff.
As luck would have it Paul Stoffregen ported the library so it can work on any linux type system using any Arduino board
(Arduino Code) https://github.com/PaulStoffregen/Bridge
(Python Code for the linux side) https://github.com/PaulStoffregen/BridgeUSB
So what it does is you set-up the Pi so when you connect the Arduino it will auto login on the comm port as root (via the usb connection) and then it should start the Bridge.py script. Now here is my problem, in fact I have 2 of them
1) The Bridge.py script does not fire (it does not start up)
2) The Arduino does not auto connect on a Pi reboot.
I can see the Arduino is connecting as root when I plug it in
root#RedPi:~# who
root ttyACM0 2016-03-10 18:01
I have the Arduino side working as I can see it is sending the data.
If I cat the port I can see it is sending the data
cat /dev/ttyACM0
run-bridge
▒XX100▒q▒XX100▒q▒XX100▒q▒XX100▒q▒XX100▒q▒XX100▒q▒X ...........................
But it does not run or execute the "run-bridge" command. But if I type it as root on a ssh session it runs.
And then if I reboot the Pi I have to pull out the plug and push it back to connect to ttyACMo again. But when I do a lsusb I can see the Arduino there. I guess I have to add a bit of config to tell linux to do it at startup.
You have to add this bit. And I was hoping it would take care of the USB at boot as well
# UDEV Rules automatically start a shell on a USB Serial device.
#
# This file must be placed at:
#
# /etc/udev/rules.d/00-bridge.rules
#
KERNEL=="ttyACM*", RUN+="/usr/bin/run-bridge-udev", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{MTP_NO_PROBE}="1"
I hope you can help me. I do not want to rewrite all my code that is working on the Yun. So if I can port it it will be great.

Python serial ports

I need to run both zigbee and SMS dongle on a raspberry pi, that means having to run both ports in a python script. Since xbee is always on ttyUSB0, is there a way I could set the dongle on ttyUSB1 or ttyUSB2 so that i dont have to configure it via gammu command everytime it is plugged in?
The best thing to do here is use a udev rule. This will allow you to symlink the device to a specific port, something like /dev/ttyXBEE and /dev/ttySMS in your case.
To accomplish this, you need to query the devices using udevadm to find some unique identifying information, then create a file /etc/udev/rules.d/99-usbserial.rules that will tell the Pi how to map the device.
This thread has an example.

Python Pyserial Windows No Port Found

I have just tried to connect to usb mobile to send sms through it using AT commands. But when i use pyserial to connect to it in a windows os, i get error could not open port, the file specified cannot be found.
>>> import serial
>>> ser = serial.Serial(0) # open first serial port
>>> print ser.name # check which port was really used
>>> ser.write("hello") # write a string
>>> ser.close()
even if i replace the 0 with any other value, like 0 -10 or 'com0','com1' etc, i still get error file specified not found, port cannot be open.
There is a command listed in pyserial documentation which lists ports or allows you to open a port
python -m serial.tools.miniterm
This command is supposed to list all serial ports. But it shows none.
I have 3 usb ports on my system. What is causing this issue.
Pyserial is not guaranteed to detect all ports. This depends on how the device and the OS communicate and if pyserial is designed to pick up on this. For Example, pyserial could not detect a LabJack U3-LV or a EPSOM-POS receipt printer I plugged in in a Win8 session (both could be detected using a linux session).
Try serial.tools.list_ports.comports() and see what it gives you.
You could also look at the pyusb module for usb connections.
Also: I recommend being careful when using numbers for ports, as the mapping may not be "common-sense" logical (i.e. 0 may not map to COM0). Use explicit string names instead.
I found the solution myself. Its pretty simple and uses the same code in the question.. I was getting blocked error because there was no modem(nokia phone) in my device manager. although i had plugged in my phone into the usb, there was no nokia pc suite installed. Once you install nokia pc suite and connect your nokia phone, in device manager -> modems your phone will appear. Just check its properties->modem and you will find the com5 or whichever number. Then use that id to connect. If you dont know this, just iterate till you find the right one.
Thanks everyone who tried to help

RS232 Serial - USB Converter device path (/dev/ttyUSB*) not getting listed

I am using an RS232 Serial - USB Converter to connect to a controller. I am trying to connect to this port programmatically.
The device is getting listed as below when I give lsusb
Bus 003 Device 003: ID 05ad:0fba Y.C. Cable U.S.A., Inc.
But I am not able to see it's device path (something like /dev/ttyUSB*).
I would like to know the way to get the path from device id (or) a way to create / find the path which can be used to open the port from a program (Ruby, Python, C)
Centos has a fairly old kernel. It may be lacking in support for your device.
Are you able to try with a newer distribution (Fedora, Ubuntu, etc) to test whether it works or not? Failing that, do you have a different dongle you can use?
You can Google for "Centos 05ad:0fba" or similar combinations to find out whether it's supported.

Categories