windows transfer file via seriabl port cmd - cmd

I was trying to figure out sending file via serial port on windows, as the below picture
I know on linux we could do
cat [file] > /dev/ttyS0
or vice verse
cat [file] < /dev/ttyS0
I also know on windows type operates samely as cat, so combined together, I modified baud rate and hope get the file transfered ...
type [file] > comport:
but as shown in picture, I was stuck in waiting forever, any idea to checkout if the file started transfering (like some verbose printout)?
after long wait ...
like one hour and a half, I got the process done (prompted with E:\scp in this case), but I did not find where the file locates in my com3 device, still need some help ...

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!

Send and read serial commands from terminal

I have a very limited list of software that I can install on an (IOT edge) device. I have minicom and chat commands (in addition to standard commands like echo and cat), and need to write to a serial device a command and read the response.
The device in question is a modem, and I need to run AT commands on it. If using minicom and setting up the menu etc. I can run these commands normally, and get the output. The problem is that I have around a thousand of these devices, so setup and data logging needs to be automated.
So within these parameters is there a way to run minicom and capture the output without any interactive elements? I have tried
minicom -S scriptfile -C outfile
where scriptfile (for now) contains following:
sleep 1
send "AT"
This seems to ignore the sleep command, and outfile is created, but is left empty. Also what would I need to add to the command that it wouldn't open a session or interactive element?

How to wait in script until device is connected

I have a Sky wireless sensor node and a script which prints the output from the node.
sudo ./serialdump-linux -b115200 /dev/tmotesky1
If I start this script before my pc detects the node, I get the following error:
/dev/tmotesky1: No such file or directory
But if I wait for example 20 seconds, I miss the initial prints (which are important).
Is there a way to detect if the /dev/tmotesky1 exists?
Something like
while [ ! -f /dev/tmotesky1 ] ; do sleep 1; print 'Waiting...'; done
Thanks in advance!
Your code indicates that you are using Linux where you can use the hotplugging mechanism.
On generic systems, you can write an udev rule (--> see with udevadmin monitor -e what happens when you attach the device) which starts e.g. a program or writes something into a pipe. When systemd is used, you can start a service (see man systemd.device).
On small/embedded systems it is possible to write a custom /sbin/hotplug program (set in /proc/sys/kernel/hotplug) instead of using udev.

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!

grep 5 seconds of input from the serial port inside a shell-script

I've got a device that I'm operating next to my PC and as it runs it's spitting log lines out it's serial port. I have this wired to my PC and I can see the log lines fine if I'm using either minicom or something like:
ttylog -b 115200 -d /dev/ttyS0
I want to write 5 seconds of the device serial output to a temp file (or assign it to a variable) and then later grep that file for keywords that will let me know how the device is operating. I've already tried redirecting the output to a file while running the command in the background, and then sleeping 5 seconds and killing the process, but the log lines never get written to my temp file. Example:
touch tempFile
ttylog -b 115200 -d /dev/ttyS0 >> tempFile &
serialPID=$!
sleep 5
#kill ${serialPID} #does not work, gets wrong PID
killall ttylog
cat tempFile
The file gets created but never filled with any data. I can also replace the ttylog line with:
ttylog -b 115200 -d /dev/ttyS0 |tee -a tempFile &
In neither case do I ever see any log lines logged to stdout or the log file unless I have multiple versions of ttylog running by mistake (see commented out line, D'oh).
I have no idea what's going on here. It seems to be a failure of redirection within my script.
Am I on the right track? Is there a better way to sample 5 seconds of the serial port?
It sounds like maybe ttylog is buffering its output. Have you tried running it with -f or --flush?
You might try the unbuffer script that comes with expect.
ttylog has a --timeout option, where you can simply specify for how many seconds it should run.
So, in your case, you could do
ttylog --baud 115200 --device /dev/ttyS0 --timeout 5
and it would just run for 5 seconds and then stop.
Indeed it also has the -f option as mentioned which flushes, but if you'd use --timeout you would not be needing that.

Resources