I'm posting this mostly as a note to myself, but maybe useful to others too. This is a simple python program to log lines of text to a file (my application is logging NMEA data from a GPS). This isn't specific to GPS, but it uses line buffering so your data strings need to end with a ' r' carriage return (or other character, if you want to change it).
I'm using the Pi's built-in UART on the GPIO pins, so I first need to disable the Linux serial console which would otherwise occupy it. This is easily done with the serial console enable/disable script from AndrewS here. Code: Traceback (most recent call last): File './log.py', line 14, in spb.readline() # throw away first line; likely to start mid-sentence (incomplete) File '/usr/lib/python2.7/codecs.py', line 296, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf8' codec can't decode byte 0xa2 in position 0: invalid start byte Apparently when starting the python Serial process asynchronously with the GPS already throwing data at the port, you may start mid-character which appears to be a non-ASCII character and causes this mysterious utf8 codec error. To fix this, I edited my previous post to tell the io code to ignore errors. The file in my first post that begins with: #!/usr/bin/python is a Python language program.
Free Download Advanced Serial Data Logger 4.2.8 Build 1020 - Input RS232 data directly into files, Excel, Access or any Windows application, and sen. I would like to make a data logger, using the analog inputs from an Arduino, which has serial-over-USB. I want to use a computer running Linux to.
![Linux Serial Data Logger Linux Serial Data Logger](http://www.alphaomega-electronics.com/1908-large_default/tmf500-data-logger-multicanal-linux-de-alto-rendimiento.jpg)
![Linux Serial Data Logger Linux Serial Data Logger](http://api.ning.com/files/GldQMZU68P83A9Bg21dFXjhNlFqwkCBzXMAaOOAKwP4Sq414uGHmcmZGzC51yZuKrO8EKPENsnzPMTlJdOFrvXHusBttubPb/img3.jpg)
That first line says which program can interpret it: the 'python' language interpreter which is located at /usr/bin/python. You save the text in a file, which can be named anything you like but traditionally ending in.py, for example serial-log.py and the file can be saved in any directory. You could use /usr/bin/ if you want, but you can put it anywhere. (Note: on the standard R-Pi install, /usr/bin/python is a symlink to the python2.7 interpreter, and not a directory.) Then, in that same directory as your python program, if you type 'python serial-log.py' (or whatever you named it) the program should run. Or you'll see some kind of error message if something went wrong.
If you want, you can also make the file itself executable: 'chmod +x serial-log.py' and then you can simply invoke it directly without first calling python, eg './serial-log.py' if you are in the same directory, or the full pathname if you aren't, for example '/home/pi/test/serial-log.py' If you want to learn how to write python yourself, there are lots of tutorial sites online, like There's even a book about Python and the R-Pi. I am doing an project using E-health sensor shield which is compatible with arduino uno and raspbery pi boards.The problem is that for my project i have to collect real time data to a file in my computer/laptop and in arduino there is no chance without using sd card. But i cant use sd card as i have to remove it from arduino and plug it into pc. The sensed data for this reason is not real time.
I have to directly store them them into a file. Is there a way exist to accomplish that????please suggest a way. THANK YOU,,PLEASE REPLY. Hello JBeale, I hope you don't mind me hijacking this thread but I thought you might be able to help me.
I have posted this question elsewer but have not received any replies. Here is my original post - if you are able to help in any way I will be eternally grateful.
============= After days of trying to get my Serial to USB to work I am no further forward - I am trying to log NMEA sentences from a GPS Module via USB to Serial connection. I have two RS232 to USB leads: Bus 001 Device 010: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port Bus 001 Device 011: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter and both work on a Windows XP machine, which is frustrating to say the least. When I try on my Pi I receive garbled text no matter what speed/parity/stopbits I choose. I am using Minicom to see the incoming data.
I have read, and tried solutions therein, many reports on this and other forums without making any progress. I'm beginning to doubt my sanity!
Does anyone have any idea however bizarre it might seem that might help me? Serial comms is not difficult but I seem to have come up against a brick wall. Hi scruss, thanks for your hints. I've tested the device on Windows and 4800 8N1 is what the GPS is using.
Regarding your suggestion to use modprobe - when I type it nothing is returned which might be a pointer. Trouble is I'm not too good with intricate Linux code so don't know where to go from here. Here are the last few lines from dmesg pi@GEO-006 ~ $ sudo dmesg -C pi@GEO-006 ~ $ sudo dmesg [33] usb 1-1.4: new full-speed USB device number 12 using dwc_otg [97] usb 1-1.4: New USB device found, idVendor=1a86, idProduct=7523 [23] usb 1-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [40] usb 1-1.4: Product: USB2.0-Ser! [19] ch341 1-1.4:1.0: ch341-uart converter detected [69] usb 1-1.4: ch341-uart converter now attached to ttyUSB0 pi@GEO-006 ~ $ And here is the output from lsusb pi@GEO-006 ~ $ lsusb Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 012: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter pi@GEO-006 ~ $ Any help will be much appreciated, thanks. I´m having similar issue.
Same vendor and productID. Same dmesg output (all looks good), but the cable cannot read info. This cable on windows works (so it´s not a cable issue) I´ve tried another cable with FTDI chipset (another vendor and product ID) and it works (so speed/bound, parity, etc are set correctly) It seems like this vendor chipset doesn´t work with this driver (Ch-341). I don´t know exactly how to do that, but should I try to force to load another module on raspberry (say pl23.) to give it a try? Thanks for you reply.
I´m not using GPIOs, these cable come with a DB9 conector in one end and an USB in another. I have a few cables. All FTDI work well. I realize my problem is with QinHeng HL-340 cables. A few of them work, but most of them not (it seem to be from different manufactures, but they seem to use this same chipset) all of them (the one that work and the ones that don´t) when I plug and DMESG, they say vendor=1a86 product=7523 attached to 'ttyUSB0' and LSUB shows: QinHeng Electronics HL-340 USB-Serial adapter in Windows all of them work. This is driving me crazy could it be because tx and rx are inverted and in windows the driver realizes that? Any other ideia?
Many thanks!!!
Serial data logger and serial data recorder solutions - KeyGrabber Hardware Keylogger Wi-Fi USB hardware keylogger released! KeyGrabber Wi-Fi keyloggers are dual-function: hardware key logger and USB flash disk for instant data retrieve. No drivers required, works with any USB keyboard, time-stamping option available. Up to 4 GB of memory! • • • • • • • • • • • • • • • • • • • • • Plug & Play Plug & play install, no access to operating system required.
USB Flash Drive mode USB technology! Retrieve entire key logger hardware memory within seconds. Available in PS/2 and USB hardware keylogger versions. Free shipping in the US! Visit for details International shipping $ or € () Purchase our products on: SerialGhost Clever serial logging The SerialGhost is a compact RS-232 and serial bus logger packed with features, such as time-stamping, Ethernet, and Wi-Fi. It has a huge memory capacity of 4 GB, and may be accessed as a USB Flash drive.
The SerialGhost Wi-Fi contains an embedded Wireless LAN module, enabling it to connect to a Wi-Fi Access Point, send E-mail reports. There is a variety of 8 different versions, covering any serial logging application at a very competitive price! Click to enlarge image!
Contents • • • • • • • • • • Introduction grabserial is a small program which reads a serial port and writes the data to standard output. The main purpose of this tool is to collect messages written to the serial console from a target board running Linux, and save the messages on a host machine. Download and Installation The latest released version is available here: (currently 1.9.3) The source code is here: Older versions I don't know why you'd want these, but here are some older versions of 'grabserial': An older version (1.5.0) is available here: Right click on the link and select 'Save Link as' to download. (See for file information) Also available here: Note: Due to MediaWiki stupidity, this file downloads with a leading upper-case letter, and a txt extension.
Please rename to lowercase on download (e.g. 'mv Grabserial.txt grabserial') To install, you must have the python-setuptools package installed (It comes bundled with a lot of distribution) and then do: sudo python setup.py install This will place 'grabserial' in your path and will also download and install the dependencies of 'grabserial' (only pyserial for 1.5.1). Pyserial (required python library) Note: You should not have to do this by hand, you should uses the setup.py script to install 'grabserial' grabserial requires the python 'serial' module. This module is not shipped with most distributions of python by default.
On some recent distributions of Linux pyserial is available as a package. For example, to install it on Fedora 12, do this (as root): 'yum -y install pyserial'. The with Angstrom needs a 'opkg install python-pyserial'. Here's a copy you can install if you don't have it. (You can check if you already have it by typing: 'python', then 'import serial' in the interactive python interpreter.
To install this, download the archive, unzip it, and following the installation instructions in pyserial-2.2/README.txt. The latest Pyserial can be obtained from: The current version as of November 2011 is 2.6, which is newer than what I've got here. Usage The grabserial program is very simple, but it provides some useful extra features that make it more than a mere 'cat' program. Use 'grabserial -h' to see online usage for the program. You can specify the serial configuration options, including the Linux device node to use, and the port speed settings on the grabserial command line.
If no options are specified, grabserial uses serial port /dev/ttyS0, at 115200 baud with '8, None and 1' (8N1) settings. Normally, the program runs in an infinite loop, reading from the serial port and writing to standard out until it is interrupted by the user (usually by typing control-C).
However, you can tell the program to stop after a certain amount of time. This is useful for including the script in automated test scenarios.
Also, you can tell the program to provide timing information for each line received. This is useful to measure the time it takes for events to happen on the target. A common thing to measure on a target running embedded Linux is bootup time. With grabserial, you can specify a pattern to match against the lines read from the serial port. When this pattern is seen, it sets a 'base time', and all subsequent time values printed out will be relative to this base. Thus, you can customize the start time for the time measurements, to make it easier to see the duration of events in the system.
Usage Examples Here are some examples of use: grabserial This will echo data seen on device /dev/ttyS0, until the user presses ctrl-C. Grabserial -v -d '/dev/ttyUSB0' -b 115200 -w 8 -p N -s 1 -e 30 -t -m 'Starting kernel.*' This opens /dev/ttyUSB0, at baud rate 115200, and 8-bit chars, No parity and 1 stop bit. This will capture and display data for 30 seconds, putting a timestamp on each line received, and restarting the timestamp at 0 when a line containing 'Kernel start' is seen. The '-v' makes grabserial verbose (printing some extra messages before starting. If you want to use grabserial with minicom on the same serial port without conflict, for example to temporarily set a boot parameter or specify a different kernel image without changing the parameters in flash, you could follow this procedure: • Prepare the grabserial command in one window but don't hit enter. • Open minicom and set the bootloader environment, bootargs, etc.
And tftp the kernel. • Use one bootloader command to delay a few seconds and boot. For u-boot this is done with something like: 'sleep 5; bootm 0x80000000'. • Immediately exit minicom and run grabserial. After the delay expires, grabserial measures boot output. Sample Output Here is sample output from grabserial.
This shows the reboot of an ARM-based system (OMAP Starter Kit). Note that the U-Boot prompt appears at time 0.313168.
The grabserial command specifies to restart the timestamps when 'Starting kernel.*' is seen. This happens at time 8.376117 after grabserial save the first character on the serial port. (Use the -l option to time from the start of grabserial.) Note that the first kernel message appears 1.517790 seconds later. Actually, the kernel starts well before this, but it takes this long before the kernel to initialize the serial port and start emitting messages. You will notice that a bunch of messages come out in rapid succession. These are messages that were queued up during the boot, before the serial console was initialized. [tbird@timdesk data]$./grabserial -v -d /dev/ttyUSB1 -e 30 -t -m 'Starting kernel.*' Opening serial port /dev/ttyUSB1 115200:8N1:xonxoff=0:rtcdtc=0 Program will end in 30 seconds Printing timing information for each line Matching pattern 'Starting kernel.*' to set base time Use Control-C to stop.
[0.000001 0.000001] [0.000433 0.000432] [0.001908 0.001475] Texas Instruments X-Loader 1.41 (Sep 1 2010 - 13:43:00) [0.295940 0.294032] mmc read: Invalid size [0.299905 0.003965] Starting OS Bootloader from MMC/SD1.