DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD General

NetBSD General Other questions regarding NetBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 10th January 2015
darktrym's Avatar
darktrym darktrym is offline
standard-bearer
 
Join Date: Feb 2011
Location: Düsseldorf
Posts: 106
Default capture serial communication with socat

Hello,
i tried to record the complete communication between my laptop and a serial device. NetBSD identies this as uslsa. I can connect via pyserial on ttyU0. Now i want to save the complete communication in both directions. So i use socat to create a pseudo device which connects to the real hardware over the tunnel. I use the following[1] command but nothing happens. Neither on the screen nor in log file.

[1]
Quote:
socat -d -lf /tmp/log.txt -v -x PTY,link=/tmp/serial,wait-slave,raw /dev/ttyU0,raw
Any ideas what igoes wrong?
Reply With Quote
  #2   (View Single Post)  
Old 10th January 2015
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

You can capture serial communication to file with tip(1) by using the following .tiprc file in your home directory:
Code:
!beautify
record='LOGS/serial-log.txt'
script
verbose
!hardwareflow
This will log everything to ~/LOGS/serial.txt
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 10th January 2015
darktrym's Avatar
darktrym darktrym is offline
standard-bearer
 
Join Date: Feb 2011
Location: Düsseldorf
Posts: 106
Default

I don't see how this could solve the problem. The connection is between a laptop and a micocontroller based device, a simple raw uart connection. When i started cu os the create a empty log file. Why should cu record data when it is not man in the middle?
Reply With Quote
  #4   (View Single Post)  
Old 10th January 2015
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

Apparently I either did not understand the problem and/or you did not describe it fully

Anyway, tip will capture serial data that arrives or comes in at the serial port it is connected to. It does log this data but does this buffered. That means only when it has saved up a rather large chunk of data it will be written to the log file. Sometimes the log file will only be written when exiting tip.

BTW this buffering mechanism could be the reason why you do not see any data in the socat log file (yet).

If you have a non-interactive program on your laptop that uses an USB to serial port to communicate (send and receive) then indeed you need something that acts as a man-in-the-middle.
Or you need to extend that program to log everything to file.

Two weeks ago I started writing a Perl script as a tip replacement. It forks a child process:
  • The parent process reads the serial device and copies it to stdout
  • The child process reads stdin and writes it to serial device

It still has a lot of imperfections but I am willing to share/post it here.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pf interfering with local lan peer communication tomp OpenBSD Security 3 2nd September 2011 09:12 PM
Multiple serial consoles via null modem cable or serial console server J65nko General Hardware 0 16th January 2010 12:01 AM
Communication with su failed amandus OpenBSD Packages and Ports 7 17th July 2008 07:17 AM
Invalid capture filter: "not ip host "! ccc FreeBSD General 2 19th June 2008 08:12 PM
Mounting a second serial hd keyboard112 Other BSD and UNIX/UNIX-like 4 12th May 2008 08:06 AM


All times are GMT. The time now is 08:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick