How to avoid modem initialization with USB gadgetfs CDC driver - linux-kernel

I have an embedded device with the USB gadgetfs CDC_ACM driver. Especially, I do:
echo "0x0525" > idVendor
echo "0xa4a7" > idProduct
ln -s functions/acm.GS0 configs/c.1
The OS running on this embedded device is custom-made and has nothing about modem initialization. The only present executable in the inittab is:
::respawn:/sbin/getty -8 115200 ttyGS0 vt100
When I link this device to a Linux PC over a USB cable and run minicom, minicom is blocked for 30 seconds with this output:
login: ATE1 E0
Password:
ATE1 E0
Where does the modem initialization come from and how can I avoid it?

Related

GSPD information stream timing out after 30 seconds

I am using a GPSD to feed GPS information to a virtual serial port. I'm generating the virtual serial port with socat, and I am listening to the virtual port using: sudo cat /dev/pts/2, where /dev/pts/2 is the drive created by socat. The GPS signal is being obtained in a C++ script . The C++ script is giving me the expected output every 1 second, but the information stream simply stops after 30 seconds.
What options can I consider in either the socat arguments or the GPSDO arguments in my C++ script, to lengthen the time past 30 seconds?
Socat in default setup has no timeout as long as both connections stay open. Apply options -d -d -d -d -lu to Socat to see in its output what happens!

Opening serial connection to Arduino through Bash

I have set up my Arduino so when I send a "0" via the serial monitor, a stepper motor turns a given amount.
I want to include this in a bash script, but I can only get this to work when the arduino serial monitor is open and entering echo 0 > /dev/tty.usbserial641 in bash. I assume this is because serial monitor is opening the connection for me.
In my struggle to open the connection in bash (without serial monitor open) I have tried all manner of options with stty -f /dev/tty.usbserial641 and have also tried connecting reset to ground with a 10uF capacitor.
Can any help me open the connection in bash without the use of arduino serial monitor?
System:
Arduino Uno rev3
OS X 10.8.4
Many thanks,
hcaw
Do the commands below work for you.
# stty -F /dev/ttyUSB0 9600 cs8 -cstopb
# sleep 0.1
# echo "0" > /dev/ttyUSB0
There is a difference between the value 0 and the ascii char 0 (48). Which one you trying to send, and which one are you trying to receive?
If you want to read the port from the terminal you can do it like this
head -n 1 /dev/ttyUSB0 //the number after n is how many lines you want to read
As a last note, I am a fan of pySerial. I would much rather write an interface in python than shell scripts.
I found a great binary written in C that solves my problem called Arduino-serial. Here's the link.
I hope this helps people with similar problems!

Mac 'screen' command shell script

I'm working on an i/o project where I have a microcontroller that communicates with my mac through a serial terminal using the screen command in Terminal.app
For example, to open the connection I type "screen /dev/tty.usbserial-number 115200" and then can type commands/data that are sent to the microcontroller
I would like to write a shell script, applescript, c program, or something simple like that that initiates the connection, sends the number "16" and then closes the connection
Thanks
Why do you need to use 'screen'? Can't you just do something like "stty -F 115200 /dev/ttyS0 ; echo '16' >/dev/ttyS0" ? Is there something specific about the setup?

How can I send a string to serial /dev/tty.* port, delay a second, disconnect from the port and continue my bash script in OSX?

This is in relation to resetting an Arduino, and then start pushing data to it from my usb xbee.
I've tried using screen, with no luck.
screen -S Xbee -d -m /dev/tty.usbserial-A900fra9 115200 *reset
I don't know how to close this session, not sure whether the args are correct, either.
to send anything to devices on /dev, you can use the > >> 2> 2>&1, etc.
Try this example from tty1 (ctrl+alt+F1):
echo "my string" > /dev/tty2
now go to tty2 (alt+F2) and you gonna see your string. It should work with any device.
and to sleep, use:
sleep 1
your problem could be also with permissions. Try it with root! ;)

How to set the baud rate for Macs in a terminal

Is it possible to set the baud rate for Macs in a terminal? If yes, how to set the baud rate in terminal through the terminal?
I am trying to talk to the Mac using an Arduino (open source microcontroller), an XBee (wireless communicator) to type in the terminal through the serial monitor. The only problem I am having is the baud rate of the serial monitor and terminal are different. I can easily change the baud rate for the serial monitor in the Arduino, but I do not know what the baud rate is for the terminal in Mac.
On Mac OS, stty seemingly can only change terminal settings for an ongoing access.
It works to either:
Access the serial interface, e.g. cat /dev/cu.usbserial, the default settings will be used at first. On a different terminal use stty, e.g. stty -f /dev/cu.usbserial 230400 to set the baud rate, the settings of the terminal accessed before will change.
There is a small time window after executing stty, in which the access can be performed with the desired parameters, e.g. stty -f /dev/cu.usbserial 230400 & cat /dev/cu.usbserial executes stty, detaches it and then immediately performs the access to the serial device.
For one line command logging serial port /dev/tty.usbserial-X's output to cat.out and terminating the logging by pressing Ctrl+C, here is the solution: trap 'kill $(jobs -p)' SIGINT ; cat /dev/tty.usbserial-X | tee cat.out & stty -f /dev/tty.usbserial-X 115200. You can type Ctrl+C to terminate logging to cat.out. (edited)
This only seems to work for the /dev/cu.* device files. I don't know the difference from /dev/tty.* files.
Minicom is an excellent tool that does exactly what you're asking for. You can get it using apt on ubuntu but should check this Tutorial out for Mac.
Keep the serial reset issue in mind if you plan on sending data to the Arduino. see http://arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection
stty 19200 or so.
Check man stty, you can set stop bits, speed, etc.
Surprised that no one mentioned picocom which could set higher bard rate up to 4000000.

Resources