Giter Club home page Giter Club logo

grabserial's Introduction

grabserial

Grabserial - python-based serial dump and timing program - good for embedded Linux development

See http://elinux.org/Grabserial for documentation and examples.

For help with command line options, use: grabserial -h

Installation

If you have the python 'serial' module, you can just place grabserial in a directory on your path, or add the directory containing grabserial to your path, or just invoke grabserial directly.

This should work:

$ sudo cp grabserial /usr/local/bin
$ grabserial

You can also install this as a python module with: 'python setup.py install' (Some users have reported problems with this - let me know if it doesn't work for you.)

Examples

$ grabserial -d /dev/ttyUSB0 -e 30 -t -m "^Linux version.*"

Grab serial input for 30 seconds (-e 30), displaying the time for each line (-t), and re-setting the base time when the line starting with "Linux version" is seen.

$ grabserial -d COM4 -T -b 115200 -e 3600 -Q -o "%" -a

Log serial data from COM4, with system timestamp (-T) with settings 115200:8N1:xonxoff=0:rtscts=0 (-b 115200) to the output file "2017-06-13T22:45:08" (-o "%"), for 1 hour (-e 3600) and then restart (-a) to create new log.

$ grabserial -d /dev/ttyUSB2 -C -q "nsh>" -c free

Send the 'free' command to the serial port (-c free), and show output until a prompt of "nsh>" is seen (-q "nsh>"). Suppress the command echo and shell prompt (-C).

$ grabserial -v -d COM10 -B 9600 -T -R 1h -o "c:\log\%Y-%m-%dT%H-%M-%S.txt"

Start a continous recording with timestamps for each line (-T) (eg: [09:07:47.330944 0.007000]) and create a new file with timestamp %Y-%m-%dT%H-%M-%S at the specified location every hour (-R).

Notice - New Default ‘-o’ Behavior

Using the '-o' option, as in the second example above, with a generic '%' or a specific pattern that includes a '%d' (date) reference will now close the output file and open a new one if the system date changes while the program is running.

If the command from the second example above is started at 11:30pm (system time), the program will capture data for one hour but will produce two output files; one with the date and time it was started and another with the date and time that the program first outputs data after the system time passes midnight.

grabserial's People

Contributors

alphasierrahotel avatar aurelihein avatar ericpeers avatar henning-schild avatar ikv avatar jeroen6 avatar jetholloway avatar liambeguin avatar pml-jpe avatar silhouette2022 avatar simeonmiteff avatar tbird20d avatar thomas-innok avatar tom-mllr avatar vynce avatar yegorich avatar zqb-all avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grabserial's Issues

'utf8' codec can't decode byte 0xc2 in position 0

Hi,
I have clone you repository to local and use command sudo python setup.py install to install .
I want to test the boot time about linux kernel,so i type:

sudo grabserial -v -d /dev/ttyUSB0 -e 50 -t -m "^U-Boot*"

Unfortunately,the grabserial was crash after few seconds.
This is what the python warning out:

File "/usr/local/bin/grabserial", line 4, in
import('pkg_resources').run_script('grabserial==1.9.6', 'grabserial')
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 719, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 1511, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/grabserial-1.9.6-py2.7.egg/EGG-INFO/scripts/grabserial", line 530, in
File "/usr/local/lib/python2.7/dist-packages/grabserial-1.9.6-py2.7.egg/EGG-INFO/scripts/grabserial", line 419, in grab

File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc2 in position 0: unexpected end of data

grabserial syntax

Hello
I would like grabserial to display readout continuously AND save the data into file at the same time. What syntax should I use? thanks

how to send special characters as -c arg?

Hi guys, i'm trying to log a response from a device that must receive special chars at the end of the command to perform actions... i can't find how, can anyone give me a hint?

need to send carriage return e new line to the device respond the command, i saw at line 681 that grabserial append \n to the command.

Cannot import grabserial as python module

Hello!
I ran the build and the install command for the setup.py, but cannot import grabserial as a module in a python script. I am new to python and a bit lost. Grabserial works amazingly from the terminal and is the only tool to read the values reliably, it would be super cool to be able to use it inside my python script.
Thanks a lot for any help! :)
Andre

Is there an error log to check? (Multiple output files being created)

I had this working on a different system just fine. I setup a new system and while running the same script, my output file folder keeps getting too many files created, seemingly at random. Is there a place to check why grabserial is starting new output files before the timer has finished?

Also, can I run a second instance of grabserial to monitor an additional serial cable/port?

Edit/Update:
Please disregard, my issue was in my script and I had to tweak it (strange it wasn't a problem on my other install with the same OS). Also running two instances no problem. All good here. Sorry to waste your time.

Output nothing when command larger then 25 characters

When I execute python C:\\grabserial -d COM9 -c "ls |cmdtool.efi 2c 18 01" -e 3 -u, the CMD window and the uefi shell have results.
When I execute python C:\\grabserial -d COM9 -c "ls | cmdtool.efi 2c 18 01" -e 3 -u, the CMD window has no results, and the uefi shell has results.
This is just an example, add a space to make the command larger than 25 characters.
I want to use this tool to execute other long commands, but I can't get information from the serial port.
Is there anyone to help with this problem? Thank you!

Don't know how to fix this

Hello
I would like to use the grabserial program but Im having trouble getting it to run properly.
I'm a newbie on a Raspberry pie so most probably is all the issues my fault.

installed the repository as follows:

git clone https://github.com/tbird20d/grabserial.git
sudo python3 setup.py install
grabserial -d /dev/ttyS0 -T -e 20 -o "%"
so it is living in
/home/pi/grabserial

and it is also in
/usr/local/bin

looks like the installation is OK, and logs a file from the serial port. if I use the -a attribute it stops after the second log with the following output.
pi@raspberrypi:~ $ grabserial -S -d /dev/ttyS0 -T -e 5 --output="%Y-%m-%d_%H-%M-%S.log" -Q -a
Traceback (most recent call last):
File "/usr/local/bin/grabserial", line 4, in
import('pkg_resources').run_script('grabserial==1.9.8', 'grabserial')
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 3019, in
@_call_aside
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 3003, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 3032, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 655, in _build_master
ws.require(requires)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 963, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 849, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'grabserial==1.9.8' distribution was not found and is required by the application
pi@raspberrypi:~ $

I have no idea what could be wrong?
I see there is a V1.9.9 release, it doesnt look like that is the one that is installed?
It seems to want to use python2.7, python 3 is installed on Raspberry Pie

to update the version can re override what is installed with what is in the Source code tar.gz file?

The --nodelta option only works with --systime

The subject says it all. The --nodelta does only work with --systime, not with --time.

$ grabserial -d /dev/ttyACM0 -v -t --nodelta
Opening serial port /dev/ttyACM0
115200:8N1:xonxoff=0:rtscts=0
Printing timing information for each line
Use Control-C to stop...
[0.000000 0.000000] main(): This is RIOT! (Version: 2022.01-devel-1387-g9e975)
[0.006011 0.006011] Hello World!
[0.007005 0.000994] You are running RIOT on a(n) nrf52840dk board.
[0.010996 0.003990] This board features a(n) nrf52 MCU.
^Cgrabserial stopped due to keyboard interrupt
$ grabserial -d /dev/ttyACM0 -v -T --nodelta
Opening serial port /dev/ttyACM0
115200:8N1:xonxoff=0:rtscts=0
Printing absolute timing information for each line
Use Control-C to stop...
[19:23:23.609021] main(): This is RIOT! (Version: 2022.01-devel-1387-g9e975)
[19:23:23.614825] Hello World!
[19:23:23.615820] You are running RIOT on a(n) nrf52840dk board.
[19:23:23.619809] This board features a(n) nrf52 MCU.
^Cgrabserial stopped due to keyboard interrupt

Is that on purpose?

Created file location

Hi
Im running grabserial from the rc.local file on raspberry pi on startup.

sudo grabserial -v -d "/dev/ttyUSB0" -b 500000 -w 8 -p N -s 1 -t -T -o "%" -a &
No problems, but the output is generated in the root directory which is not desirable.
I would like the file to be generated in /home/pi/

sudo grabserial -v -d "/dev/ttyUSB0" -b 500000 -w 8 -p N -s 1 -t -T -o /home/pi/"%" -a &
any change to the "%" just creates a file with % filename.

sudo /home/pi/grabserial -v -d "/dev/ttyUSB0" -b 500000 -w 8 -p N -s 1 -t -T -o "%" -a &
this tells me grabserial does not exist...

Please help, am I missing something?

Coudln't open serial port

So this is what happened, i think this has been an issue before?
I'm trying to log some serial data from the GPIO pins with grabserial.
I'm using a freshly downloaded raspbian image on an RPI3B+
Grabserial keeps telling me the serial ports are not found even when using the -S option.
They show up when i look in dmesg.
I couldn't wast too much time at the moment so i reverted to using this script :
http://www.davesmotleyprojects.com/raspi/raspi-data-logger/raspi-data-logger.html
Which worked right from the getgo....
Very strange.

command string - TypeError: unicode strings are not supported, please encode to bytes

When attempting to send a serial command on startup I get the following errror.

smart@smart:~/grabserial-master$ python3 ./grabserial -T -b 115200 -d /dev/ttyUSB0 -c 'logcat -c;logcat -vtime'
Traceback (most recent call last):
  File "./grabserial", line 530, in <module>
    grab(sys.argv[1:])
  File "./grabserial", line 402, in grab
    sd.write(command + "\n")
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 532, in write
    d = to_bytes(data)
  File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 63, in to_bytes
    raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: 'logcat -c;logcat -vtime\n'

Using Python3 on Xubuntu. Fails on xfce-term and xterm.

Feature request: Would it be possible to add an offset/trigger to the midnight file change?

My system being logged does quite a lot of stuff at midnight and issues its daily report a short time after midnight.
That should not be unusual, isn't it?
Would it be possible to add an offset if [x] minutes before changing the logfile?
Better: change the logfile only upon a given trigger keyword in the received data, so segmentation differences can be avoided.
Thank you.

Please set version by tag

Hi,

grabserial was already released 1.9.1, but version of tag does not set.
Could you set version by tag?

Date in filepath no longer works

I wanted to use subdirectories of year, month and day for output files so I used following option in grabserial (on Windows): -o "C:\data\%%Y\%%m\%%d\%%FT%%H00.txt"

I forked the repo and added code to make sure output directories would automatically be created if they didn't exist (otherwise grabserial quits with error, file not found).

I have just pulled latest version and I can see there has been substantial changes to the output filenaming. Now the output directories are created with literal strings %Y, %m, %d instead of actual year, month and date. I have had a look in the code around lines 525-536 but I can't quite understand where these are getting converted to strings. If you can point me to the correct code it would be a great help.

Thanks

Control characters in output

Two of the things I am logging have strange character showing in the output. Here is an example of one:

grabserial1

grabserial2

I think these are RS232 control characters. Interestingly these do not show when I capture the serial using Tera Term:

image

image

I don't want to see or log these characters. Is there anything I can do?

Triggering newline on ']' stop condition from buspirate i2C snoop macro

Here's a little hack implemented to make the output of the BusPirate's I2C snoop macro display a little better. Causes a newline on each ']' which is the stop condition (end of read/write).
mungewell@2ae8140

Very custom application, and probably not worthy of a pull request. Mainly uploaded it so I can find it in future...

Maybe if there is a need, we could add a command to specify a character on which to break a line.

Ignore partial lines on invocation

Hi all, me again. I'm finally at the stage where I am about to replace our current logging system with grabserial in production.

There is one slight niggle though - sometimes at the invocation of grabserial, it catches only part of a line of data, like this example:

[Wed Feb 17 11:17:27.154989 2021] 4,-627,146,-12
[Wed Feb 17 11:17:27.197966 2021] $1616707200,-37,70,-65,-626,146,-793,-35311,11838,-148845,,,,-55361,-30709,-12928,-76320,-10393,-37727,-104527,14,-3,15,,,
[Wed Feb 17 11:17:27.237997 2021] $1616707456,179,5,6,-628,147,-793,-35603,11166,-148143,,,,-55363,-30709,-12928,-76319,-10393,-37726,-104524,16,-5,15,,,
[Wed Feb 17 11:17:27.277551 2021] $1616707968,-35,1,5,-625,146,-796,-35545,11780,-148699,,,,-55366,-30708,-12925,-76318,-10397,-37722,-104520,13,-3,18,,,
[Wed Feb 17 11:17:27.318006 2021] $1616708480,-107,0,5,-628,146,-798,-36100,11809,-148611,,,,-55366,-30707,-12926,-76318,-10395,-37723,-104520,16,-3,20,,,
[Wed Feb 17 11:17:27.357688 2021] $1616708736,251,6,76,-629,146,-797,-35895,11750,-148406,,,,-55373,-30704,-12920,-76315,-10402,-37715,-104510,18,-3,19,,,
[Wed Feb 17 11:17:27.398016 2021] $1616709248,-250,-2,4,-627,145,-793,-35954,11837,-149311,,,,-55374,-30699,-12921,-76316,-10397,-37711,-104511,15,-3,15,,,
[Wed Feb 17 11:17:27.438019 2021] $1616709504,36,2,6,-627,147,-795,-36275,11897,-148436,,,,-55379,-30691,-12923,-76316,-10389,-37704,-104510,16,-4,16,,,
[Wed Feb 17 11:17:27.478024 2021] $1616710016,-35,1,75,-626,146,-796,-35808,11370,-148933,,,,-55378,-30694,-12921,-76316,-10393,-37705,-104509,15,-3,18,,,
[Wed Feb 17 11:17:27.518002 2021] $1616710272,-109,69,-65,-630,148,-799,-36217,11692,-149371,,,,-55378,-30693,-12923,-76316,-10391,-37706,-104510,18,-5,20,,,
[Wed Feb 17 11:17:27.558034 2021] $1616710784,36,2,75,-631,145,-798,-35340,11312,-148669,,,,-55376,-30693,-12926,-76317,-10386,-37708,-104514,19,-3,20,,,
[Wed Feb 17 11:17:27.598036 2021] $1616711040,-107,0,75,-627,145,-796,-35749,11166,-148699,,,,-55375,-30690,-12928,-76318,-10381,-37708,-104518,15,-2,17,,,
[Wed Feb 17 11:17:27.638021 2021] $1616711552,-107,0,5,-631,145,-802,-36159,11050,-149633,,,,-55378,-30686,-12925,-76318,-10382,-37701,-104515,20,-3,24,,,
[Wed Feb 17 11:17:27.678046 2021] $1616712064,107,3,6,-628,146,-794,-35486,10670,-148728,,,,-55373,-30697,-12928,-76317,-10387,-37714,-104516,17,-3,16,,,
[Wed Feb 17 11:17:27.718042 2021] $1616712320,-178,-1,75,-628,146,-796,-35399,11370,-147413,,,,-55373,-30697,-12927,-76317,-10388,-37713,-104516,17,-3,18,,,

As you can see the very first line has only caught part of the output. Is there a simple way of ignoring these partial lines (e.g. waiting for line break)?

-n or --nodelta not working

When trying to use either -n or trying --nodelta results in:
Error parsing command line options

Command is:
grabserial -d /dev/ttyUSB0 -b 9600 -T -n

When using the following it's fine:
grabserial -d /dev/ttyUSB0 -b 9600 -T

Logging binary UART stream to file not working, only with --hex-output option

Hi,

I'm trying to log raw data from my ublox GPS receiver on my raspberry pi using the UART serial port.
Baud rate of 115200 and default 8N1 encoding.

The messages I expect to read should start with B5 62 02 15 in HEX.

I'm using the following command:

grabserial -S -d "/dev/ttyS0" -B 115200 -e 10 -o 'test_%Y-%m-%d_%H:%M:%S.ubx' -Q -v -x

The output, once converter in HEX looks like this:

0000: 62 15 01 49 01 41 66 08 12 0C 01 01 19 0F 76 6A 	b¿¿I¿Af¿¿¶¿¿¿¿vj
0010: 77 41 78 00 41 02 68 12 45 00 14 00 00 26 04 03 	wAx¿A¿h¿E¿¿¿¿&¿¿
0020: 07 07 00 62 06 76 41 4C 7A 34 07 0A 41 55 0A 44 	¿¿¿b¿vALz4¿¬AU¬D
0030: 00 10 00 00 1D 06 05 08 07 00 5E 26 71 75 41 69 	¿¿¿¿¿¿¿¿¿¿^&quAi
0040: 7D 43 41 42 00 1D 00 00 25 04 03 07 0F 00 6C 77 	}CAB¿¿¿¿%¿¿¿¿¿lw
0050: 41 02 01 36 41 50 73 00 05 00 00 20 06 05 08 07 	A¿¿6APs¿¿¿¿ ¿¿¿¿
0060: 00 03 2A 2F 40 74 78 41 2D 46 3A 10 41 51 28 45 	¿¿*/@txA-F:¿AQ(E
0070: 00 17 00 00 00 00 19 09 0F 0A 01 00 75 75 6C 77 	¿¿¿¿¿¿¿Δ¿¬¿¿uulw
0080: 41 21 07 64 41 1B 37 02 0C 00 00 23 06 04 08 07 	A!¿dA¿7¿¶¿¿#¿¿¿¿
0090: 00 75 79 77 41 32 41 3C 7E 34 02 19 00 00 00 00 	¿uywA2A<~4¿¿¿¿¿¿
00A0: 15 0A 0F 0C 01 00 33 7E 12 29 79 41 3D 42 4B 0C 	¿¬¿¶¿¿3~¿)yA=BK¶
00B0: 1E 41 54 16 44 02 02 00 00 20 06 05 08 07 00 3C 	¿AT¿D¿¿¿¿ ¿¿¿¿¿<
00C0: 4C 12 03 7F 79 41 42 70 62 75 41 02 4C 4D 02 18 	L¿¿�yABpbuA¿LM¿¿
00D0: 00 00 1C 07 09 08 07 00 0E 7D 45 72 41 67 36 5C 	¿¿¿¿Δ¿¿¿¿}ErAg6\
00E0: 78 41 5F 02 12 00 00 26 05 03 07 07 00 47 32 77 	xA_¿¿¿¿&¿¿¿¿¿G2w
00F0: 41 61 41 2C 51 0C 02 0C 06 00 24 1D 06 06 08 07 	AaA,Q¶¿¶¿¿$¿¿¿¿¿
0100: 00 6F 75 41 75 41 0C 17 00 1D 03 00 1C 08 07 08 	¿ouAuA¶¿¿¿¿¿¿¿¿¿
0110: 07 00 54 62 01 07 5C 00 08 07 03 16 0F 33 37 05 	¿¿Tb¿¿\¿¿¿¿¿¿37¿
0120: 00 00 00 0B 03 01 0C 66 1F 05 16 47 1C 54 08 00 	¿¿¿¿¿¿¶f¿¿¿G¿T¿¿
0130: 07 00 5F 05 00 00 00 00 10 00 00 00 15 00 00 00 	¿¿_¿¿¿¿¿¿¿¿¿¿¿¿¿
0140: 39 5A 00 00 00 00 0F 6E 00 00 00 00 49 32 00 00 	9Z¿¿¿¿¿n¿¿¿¿I2¿¿
0150: 00 00 00 00 00 00 0B 62 01 22 14 00 08 18 0C 00 	¿¿¿¿¿¿¿b¿"¿¿¿¿¶¿
0160: 01 00 00 05 00 00 00 44 02 00 00 3C ->62 02 15<- 01 	¿¿¿¿¿¿¿D¿¿¿<b¿¿¿
0170: 1D 5A 64 3B 4B 01 41 66 08 12 0C 01 01 4E 1A 05 	¿Zd;K¿Af¿¿¶¿¿N¿¿
0180: 16 6A 77 41 4C 70 41 06 6A 12 45 00 14 00 00 26 	¿jwALpA¿j¿E¿¿¿¿&
0190: 04 02 07 07 00 7C 1D 08 06 76 41 71 04 41 2D 00 	¿¿¿¿¿|¿¿¿vAq¿A-¿
01A0: 44 00 10 00 00 1D 06 06 08 07 00 33 31 79 75 41 	D¿¿¿¿¿¿¿¿¿¿31yuA
01B0: 41 41 61 42 00 1D 00 00 25 04 03 07 0F 00 2E 71 	AAaB¿¿¿¿%¿¿¿¿¿.q
01C0: 77 41 20 6F 36 41 3A 66 00 05 00 00 20 06 06 09 	wA o6A:f¿¿¿¿ ¿¿Δ
01D0: 07 00 53 6F 39 74 78 41 64 36 10 41 6D 28 45 00 	¿¿So9txAd6¿Am(E¿
01E0: 17 00 00 00 00 19 09 0F 0A 01 00 49 77 41 3B 4E 	¿¿¿¿¿¿Δ¿¬¿¿IwA;N
01F0: 41 15 37 02 0C 00 00 23 06 04 08 07 00 5C 77 41 	A¿7¿¶¿¿#¿¿¿¿¿\wA
0200: 7E 1C 41 18 4E 33 02 19 00 00 00 00 15 0A 0F 0C 	~¿A¿N3¿¿¿¿¿¿¿¬¿¶
0210: 01 00 32 12 21 25 79 41 44 6A 75 1B 41 42 1C 44 	¿¿2¿!%yADju¿AB¿D
0220: 02 02 00 00 20 06 05 08 07 00 62 0A 7F 79 41 51 	¿¿¿¿ ¿¿¿¿¿b¬�yAQ
0230: 7A 41 07 5E 4D 02 18 00 00 1C 07 09 08 07 00 73 	zA¿^M¿¿¿¿¿¿Δ¿¿¿s
0240: 02 4E 72 41 66 67 78 41 5F 02 12 00 00 26 05 02 	¿NrAfgxA_¿¿¿¿&¿¿
0250: 07 07 00 40 77 41 41 19 48 0C 02 0C 06 00 25 1C 	¿¿¿@wAA¿H¶¿¶¿¿%¿
0260: 07 07 08 07 00 5A 6C 39 77 75 41 08 64 75 41 7C 	¿¿¿¿¿Zl9wuA¿duA|
0270: 17 00 1D 03 00 1C 08 07 08 07 00 62 01 07 5C 00 	¿¿¿¿¿¿¿¿¿¿¿b¿¿\¿
0280: 08 07 03 16 0F 33 37 05 00 00 00 47 17 03 01 0C 	¿¿¿¿¿37¿¿¿¿G¿¿¿¶
0290: 66 1F 05 16 47 1C 54 08 00 07 00 5F 05 00 00 00 	f¿¿¿G¿T¿¿¿¿_¿¿¿¿
02A0: 00 09 00 00 00 05 00 00 00 0B 00 00 00 39 5A 00 	¿Δ¿¿¿¿¿¿¿¿¿¿¿9Z¿
02B0: 00 00 00 2C 6E 00 00 00 00 49 32 00 00 00 00 00 	¿¿¿,n¿¿¿¿I2¿¿¿¿¿
02C0: 00 00 00 58 75 62 01 22 14 00 08 18 0C 00 01 00 	¿¿¿Xub¿"¿¿¿¿¶¿¿¿
02D0: 00 05 00 00 00 45 02 00 00 65 59 ->62 02 15<- 01 4C 	¿¿¿¿¿E¿¿¿eYb¿¿¿L
02E0: 01 41 66 08 12 0C 01 01 16 1B 42 6A 77 41 65 5C 	¿Af¿¿¶¿¿¿¿BjwAe\
02F0: 41 18 65 12 45 00 14 00 00 26 04 02 07 07 00 72 	A¿e¿E¿¿¿¿&¿¿¿¿¿r
...

The message is not coming up, the B5 character µ (mu) never comes up.

But when I add the --hex-output option, the hex file content seems to show the correct messages:

->B5 62 02 15<- 90 01 1D 5A 64 3B 43 84 01 41 66 08 
12 0C 01 01 66 16 D2 89 7A F4 EC 6A 77 41 6C 45 
7B 49 E3 C3 9E 41 0F 78 12 45 00 14 00 00 F4 FB 
26 05 03 07 07 00 89 0A 4F 46 1F 06 76 41 E4 33 
20 EF 21 EF 9C 41 5F 15 EF 44 00 10 00 00 F4 FB 
1D 06 05 07 07 00 85 04 38 2C 54 F0 75 41 43 26 
6B 59 80 D2 9C 41 50 8A 42 C5 00 1D 00 00 F4 FB 
25 05 03 07 0F 00 2D 29 4C 3F 5B C2 77 41 FA 3A 
E1 06 BF 36 9F 41 7F 52 E6 C4 00 05 00 00 A8 98 
20 06 05 08 07 00 D6 CC 93 CC 59 74 78 41 91 C7 
F3 B0 4B 10 A0 41 3A 79 28 45 00 17 00 00 00 00 
19 09 0F 0A 01 00 F8 16 26 B1 CE 8A 77 41 D4 E8 
B9 C6 C5 ED 9E 41 E1 16 37 C5 02 0C 00 00 F4 FB 
23 06 03 07 07 00 19 5D 6B CE EC 80 77 41 E1 B4 
4C E0 C9 E0 9E 41 10 35 C4 02 19 00 00 00 00 15 
0A 0F 0C 01 00 6E CE 1D D7 38 AC 79 41 B9 93 47 
67 28 DD A0 41 C8 0E CF 44 02 02 00 00 F4 FB 20 
06 05 08 07 00 A8 2F 02 D3 E3 7E 79 41 F2 C5 9E 
DA 60 BF A0 41 7E 4F 4D C5 02 18 00 00 F4 FB 1C 
07 08 08 07 00 C2 7D C5 72 23 A0 72 41 49 0C 6E 
7A 2F 78 98 41 C5 A0 5F C5 02 12 00 00 F4 FB 26 
05 03 07 07 00 5D 63 AC 19 CD 8A 77 41 AC 96 0B 
8A DB B2 97 41 12 48 0C C5 02 0C 06 00 98 21 1C 
07 05 07 07 00 80 DB 81 26 52 F0 75 41 E3 20 61 
7C 79 75 96 41 B9 A0 17 C5 00 1D 03 00 F4 FB 1C 
08 08 08 07 00 D8 CF B5 62 01 07 5C 00 D0 94 8D 
08 E5 07 03 16 0F 33 12 37 05 00 00 00 27 AF DA 
17 03 01 EA 0C CD 66 1F 05 19 A2 47 1C 63 54 08 
00 69 9B 07 00 60 05 00 00 14 0D 00 00 0D 00 00 
00 20 00 00 00 FB FF FF FF 22 00 00 00 39 5A F9 
00 EE 00 00 00 D0 7E 6E 00 9B 00 00 00 DC CA 49 
32 00 00 00 00 00 00 00 00 B1 4F B5 62 01 22 14 
00 D0 94 8D 08 1A 17 0C 00 DF 01 00 00 05 00 00 
00 43 02 00 00 97 E6 ->B5 62 02 15<- 90 01 B6 F3 FD 
D4 44 84 01 41 66 08 12 0C 01 01 2E 17 2A 85 51 
62 E7 6A 77 41 A7 6B 2D F7 DB C3 9E 41 55 69 12 
45 00 14 00 00 F4 FB 26 04 03 07 07 00 E8 49 BF 
BA 1A 06 76 41 76 2B EC F4 1B EF 9C 41 BB 1D EF 

I cannot explain it myself and could not find any option that would solve the problem.

Software version:

  • grabserial version 2.1.5
  • Python 3.7.3
  • Raspberry Pi 3 Model B Plus Rev 1.3
  • GNU/Linux Raspbian GNU/Linux 10 (buster)

Porting grabserial from Python2 to Python3

Python2 is going to retire very soon upstream on January 1, 2020 . As a result, with upcoming Fedora 31 and onward releases, Python2 packages are getting removed . Is there a plan to port grabserial from Python2 to Python3?

I tried to rebuild python-grabserial package as it is with Python3, but running it throws some error:

grabserial 
  File "/usr/bin/grabserial", line 190
    if opt in ["-d", "--device"]:
                                ^
TabError: inconsistent use of tabs and spaces in indentation

Using -c <command> or --command="<command>"

Hi,

I noticed that for command to work properly I had to change the code

from:

if command:
    sd.write(command + "\n")
    sd.flush()

to:

if command:
    sd.write(command + "\r")
    sd.flush()

Thanks,
Wojtek

putserial - SyntaxError: multiple exception types must be parenthesized

HEAD on Windows 10.

C:\Users\swood\Downloads\grabserial-bp-i2c-snoop-20220126>"c:\Program Files\Python310\python.exe" putserial -h
  File "C:\Users\swood\Downloads\grabserial-bp-i2c-snoop-20220126\putserial", line 191
    except getopt.GetoptError, err:
           ^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized

Split files on start of hour

Is it possible to automatically split on the start of the hour? I'm looking at logging some high frequency serial data from a scientific instrument and I'd like to split the files per hour, but it needs to be accurate.

So far the only way I can think of is to use -e 3600 and invoke grabserial by a cron job on the start of the hour or something, but I need the splitting to be really accurate as I will potentially be dealing with serial data that's coming in at 50Hz.

If anyone has any suggests I would love to hear them!
Thanks

Grabserial as startup service/file/bash script

I made a script to capture ttyAMA0 as follows..
#! /bin/bash sleep 5 grabserial -v -d /dev/ttyAMA0 -T -b 115200 -e 3600 -Q -o "/home/pi/file-%d-%m-%Y-%H.%M.%S.txt" -a

This runs well from the terminal but I can't get it to work as a startup script in either cron job or systemd service or even when I add it to update-rc.d

On update-rc.d, it just create the file, but does not read any data into it. As a systemd service, the script keeps looping- opens, doesn't store any data, closes, opens another files; all within seconds. I think this has to do with systemd configurations. In a cron job, the job just wouldn't start.

Is it possible grabserial was not written to be suitable as a startup?

Functionality to support continuous logging

Hi Tim.

I've been using grabserial for a couple of years now to do some continuous data logging from an Arduino-based sensor. With the burgeoning IOT trend, I'm sure I'm not the only one doing that. In support of that effort though, I tweaked the code to do a couple of things differently.

  1. I added a command line option to append to the output file rather than overwrite it
  2. When there is a date in the output filename, I close it and open a new one if the date has changed.

I've also configured a systemd setup that will start the process of serial data logging as soon as the port is available - all of which would help to address things akin to issue #30

I am wondering if you would be open to considering a pull request or two to implement this functionality for the benefit of others like me that are interested in continuous data logging using grabserial. The systemd setup could be in the form of either notes/documentation or an example file (or both).

Kind regards.
Allen

unable to open port

Dears, i try to connect a scale via usb port.
few months ago it was working fine, but now is no working.
I try to read my serial port with this command
grabserial -d /dev/ttyACM0 -e 1 -o /tmp/data -Q
and that error appear :

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 323, in _reconfigure_port
orig_attr = termios.tcgetattr(self.fd)
termios.error: (25, 'Inappropriate ioctl for device')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/grabserial", line 630, in
grab(sys.argv[1:])
File "/usr/bin/grabserial", line 442, in grab
sd.open()
File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 272, in open
self._reconfigure_port(force_update=True)
File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 326, in _reconfigure_port
raise SerialException("Could not configure port: {}".format(msg))
serial.serialutil.SerialException: Could not configure port: (25, 'Inappropriate ioctl for device')
Can your program need other python than my distro take inside?
I have this python related packages on a archlinuxarm in a rpi4
pacman -Q |grep python
python 3.8.4-1
python-acme 1.6.0-1
python-appdirs 1.4.4-1
python-asn1crypto 1.3.0-1
python-cffi 1.14.1-1
python-chardet 3.0.4-5
python-configargparse 1.2.3-1
python-configobj 5.0.6-7
python-cryptography 3.0-1
python-distro 1.5.0-1
python-future 0.18.2-3
python-gobject 3.36.1-1
python-idna 2.10-1
python-josepy 1.3.0-1
python-mock 3.0.5-3
python-ordered-set 4.0.2-1
python-packaging 20.4-1
python-parsedatetime 2.6-1
python-pbr 5.4.5-1
python-ply 3.11-5
python-pycparser 2.20-1
python-pyopenssl 19.1.0-2
python-pyparsing 2.4.7-1
python-pyrfc3339 1.1-5
python-pyserial 3.4-4
python-pytz 2020.1-1
python-requests 2.24.0-1
python-requests-toolbelt 0.9.1-3
python-setuptools 1:49.2.0-1
python-six 1.15.0-1
python-urllib3 1.25.10-1
python-zope-component 4.6.2-1
python-zope-deferredimport 4.3.1-4
python-zope-deprecation 4.4.0-3
python-zope-event 4.4-3
python-zope-hookable 5.0.1-1
python-zope-interface 5.1.0-1
python-zope-proxy 4.3.5-1

Can't send command ending with \r\n

Hi,

I am trying to send a command ending with \r\n , however it doesn't work.

my command:
grabserial -d /dev/ttyUSB0 -b 2000000 -c adc\r

Some troubleshooting notes:
I print the output of the command variable from line 681 of the grabserial code

if command:
            command += u"\n"
            print(command, end='')
            sd.write(command.encode("utf8"))
            sd.flush()

my output:
adcr

It seems the \r character is not recognized

My temporary fix:
add \r character together with \n character on line 681 to

if command:
            command += u"\r\n"
            sd.write(command.encode("utf8"))
            sd.flush()

Kindly advise if there are any other solutions for this

Error when closing

Hello,
I am running grabserial to log moisture data from an Arduino on a Raspberry Pi.

The command that I run is as follows:

grabserial -d /dev/ttyACM0 -T -e 3600 -o "%Y-%m-%d.txt" -a -Q

This seems to work fine, logging the data to the file, (I know the length of time/timestamp doesn't make sense, I haven't finalized that) but when I press Ctrl+C I get the following error:

^CTraceback (most recent call last):
  File "/usr/local/bin/grabserial", line 4, in <module>
    __import__('pkg_resources').run_script('grabserial==1.9.6', 'grabserial')
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 739, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1501, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/grabserial-1.9.6-py2.7.egg/EGG-INFO/scripts/grabserial", line 530, in <module>

  File "/usr/local/lib/python2.7/dist-packages/grabserial-1.9.6-py2.7.egg/EGG-INFO/scripts/grabserial", line 419, in grab

  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 472, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
KeyboardInterrupt

Thanks

grabserial stops printing

Hi,

I used grabserial for checking the startupcode by using the serial port of my target device, on the host side it's connected to a ttyUSB Port.

When I start grabserial only a few messages are shown and it stops printing out the lines (i know there are more, since i usually communicate with other serial programs like putty, without any problems). The program doesn't quit, it just freezes, i have to break it with [CTRL-C].

For debugging reasons, I added a loop at my startup, and then it printed out everything. So what i guess: the script is a bit slow on processing, since it only prints messages out as long as it physically receives anything. I already tried to force printing out the missing message by some flush commands, without any success.

I like that script, the results come in quiet handy, but unfortunately I can't use it as it is at the moment.

AutoStart - Terminal - Grabserial - Append File

Hi Tim, I'm new to Arduino, Raspberry & Python. But that has not stopped me from taking temperature measurements w/ Arduino Mega and then using your GREAT program transferring them to a Raspberry Pi 3+ file. Wanted to create a headless capability to do that. I'm learning Python fast but will NEVER in million light years will be as good as you are. Can you help with the following:

  1. Autostart (on power up) Grabserial with parameters [python grabserial -t >> ] but must be run in terminal so that must start first. I tried with lxterminal (see code below). Got grabserial to start but no way to pass parameters? Looked at your code and most is greek (too bad it is not in fortran) Was thinking it could be configured to invoke parameters and file name w/o passing when first run via terminal?
  2. If this works the Data File would get written over each time the PI boots is there any way to invoke "a" append, or change file name for each session?
  3. Can the file be located on a USB drive? Not sure how to pass drive location to grabserial.
    Sorry for being so needy but graduated from College with slide rule in hand.

Best Regards & Thanks

[Desktop Entry]
Type=Application
Name=Headless.Desktop
Comments=Headless Commands
Exec=lxterminal -e python grabserial
Hidden=false
terminal=true     

/dev/ttyAMA0 not found when using command line, but when edited in grabserial.py, works fine

Good evening!

Was happy to find grabserial - I want to use a Raspberry Pi to log serial data...and grabserial seemed like it would make it easy.

Initially, I couldn't get grabserial to work properly...but figured out how to make it work. I suspect there may be an issue, but I'll admit not being a programmer-type, it is possible that I'm just dumb and this is user error. ;)

First...I obtained grabserial via wget from https://github.com/tbird20d/grabserial/releases/latest which is version 1.8.1.

Second, I un-tar'ed it, then did the install as shown here http://elinux.org/Grabserial:

sudo python setup.py install

Executing grabserial as follows:

grabserial -d /dev/ttyAMA0 -b 19200 -e 30 -t -T -o test.txt

Returns:

Error: serial device '/dev/ttyAMA0' does not exist

(Note: being that this is a Raspberry Pi, I need to not that I've disabled the serial console...and was able to get other scripts to pull data from /dev/ttyAMA0 so I know it exists.)

Looking around on the internet, I saw another user who edited the source with his settings, then executed it with python. So I did the same, downloaded the source and changed the following:

    sd.port="/dev/ttyAMA0"
    sd.baudrate=19200

Now when I execute it with python:

python grabserial.py -e 30 -t -T -o test.txt

Everything works perfectly. I suspect there is something going on with how the /dev/ttyAMA0 is getting passed from the command line into the program?

thanks much,
ben, kd5byb

Shebang Python location could cause not find the interpreter

Context

Current shebang line in grabserial/putserial/setup.py files, that specify where to search by default for the Python interpreter, points to /usr/bin/python, but there is systems where the python binary could be in other path or could be multiple python versions, and can cause the scripts to not be executed directly:

./grabserial
-bash: ./grabserial: /usr/bin/python: bad interpreter: No such file or directory

Change Recomendation

Modify current shebang:

#!/usr/bin/python

To use env, that search in PATH enviroment variable fro the interpreter and is a best way for portability (find the interpreter in most systems):

#!/usr/bin/env python3

What do you think about it?

Regards.

grabserial as HEX dump data logger

Hi there!

It will not be a report of issue, it will be more like question/idea for software.
I want to make serial port HEX data logger from Pi4.

I use grabserial software, but it saves and show data only after decoding, but I need to see raw HEX DUMP. I need to see raw data, because its communication commands. Like command to startup: 0xGG 0xZE 0x22, not a word.

I modified file "grabserial" by deleting all decode of UTF-8, but it still continue to decode it. If i understand correctly, grabserial works with unicode, so it's extremely bad idea to do but still i did it.

Now when i send to serial port 0xCC 0xFC from grabserial I see:
[14:25:05.770066 0.000002] ▒

But I want to see and save to LOG:
[14:25:05.770066 0.000002] CC FC

Is there any ideas how to get raw HEX data ?

P.S.

I am new in Linux and Raspberry PI. In case if I asked or write something stupid, i'm sorry.

Thanks in advance,
Best regards,
Ainars

Why there is no output?

`#dmesg | grep console
[    0.000000] ACPI: SPCR: console: uart,mmio,0x3f00002f8,115200
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.10.134-001.ali5000_1003_683de22baf_cbp.alios7.aarch64 root=LABEL=ROOT ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=us biosdevname=0 console=tty0 scsi_mod.scan=sync nohz=off cgroup.memory=nokmem iommu.strict=0 virtio_ring.vring_force_dma_api=1 nokaslr crashkernel=0M-2G:0M,2G-256G:256M,256G-1024G:320M,1024G-:384M console=ttyS0,115200 ipv6.disable=1 rd.driver.pre=ahci LANG=en_US.UTF-8 softlockup_panic=1 numa_spinlock=off
[    0.000415] printk: console [tty0] enabled
[   10.203915] printk: console [ttyS0] enabled`
#grabserial -v -d /dev/ttyS0 -e 30 -t
Opening serial port /dev/ttyS0
115200:8N1:xonxoff=0:rtscts=0:rts=1:dtr=1
Program set to end in 30 seconds
Printing timing information for each line
Use Control-C to stop...
grabserial stopped due to time expiration

When I run grabserial, there is no output. I don't know if it's the cause of ttyS0? However, ttyUSB* does not exist on my computer. So, I use dmesg | grep console find ttyS0, can it replace ttyUSB0? Or, how can I find the corresponding serial port to replace the ttyUSB0?

Specify file storage directory and format

hi tbird20d,

Nice application here, seems to be suitable for my application.

However, I am looking into specifying a directory for the grabbed files (using the app to log data from serial on a RPi3, and prefer to save the files to an external pen drive). I would expect that to be a parsed variable in -o "%". Do you have a plan of doing this in the future? Any current work around you may suggest?

Python 3.x mixed tabs and spaces

I'm trying to run in Python 3.5.2, but I keep getting this error:

TabError: inconsistent use of tabs and spaces in indentation

According to PEP8 mixing tabs and spaces is disallowed.

If you are testing using 2.x could I get you to add the -tt option so the code will be compatible with Python 3?

Thanks!

High CPU usage on Pi Zero 2 W

Hello,
I am using grabserial on Raspberry Pi Zero to capture logging data and I am noticing high CPU usage.

Please see the below screenshot.

image

When I use the following code to understand the high CPU usage, I observe 25% CPU usage.

import serial
with serial.Serial('/dev/tty.usb-1.2, 2000000, timeout=10) as ser:
    while True:
            data = ser.read().decode('utf-8')
            print(data, end='')

However, when I test the following code with time.sleep(0.01) at the end of while True loop, I observe significant improvement in CPU usage.

import serial
import time
with serial.Serial('/dev/ttyUSB0', 2000000, timeout=10) as ser:
    while True:
        if (ser.in_waiting > 0):
            data = ser.read(ser.in_waiting).decode('utf-8')
            print(data, end='')
        time.sleep(0.01)

Please see the image below. The name of the above script is pyserial.py
image

Let me know your thoughts regarding this as I would like to use grabserial timing functionality on resource-constrained devices such as Raspberry Pi Zero 2 W.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.