1

I want to determine exactly what data is sent by a controller to a off-board motor controller that has its own processor. I have not had success with plain text commands or json commands either. There is a program that the motor controller works with, however I need my own program to send the same information in the right format. Software being used is Coolterm and a tinyg board.

With interceptty I have been able to get one way communication back from the motor controller but not the data being sent to the controller. "interceptty -s 'ispeed 115200 ospeed 115200' /dev/ttyUSB0 /dev/tty<>" In the "<>" I have tried my own words, letters, or other directories like S1. I have also tried /dev/<> but coolterm won't recognize it in the dropdown menu.

No real error message just can't get data being sent by the computer. Can get data received.

Lumos
  • 570
  • 1
  • 11
  • 24
evan
  • 169
  • 3
  • 12
  • Are you using hardware [flow control](https://github.com/synthetos/TinyG/wiki/Flow-Control-and-Footers)? – Marcos G. Jul 23 '19 at 04:42

1 Answers1

1

In my setup, I have two real (well, they are actually USB-to-serial adaptors) serial ports on /dev/ttyUSB0 and /dev/ttyUSB1. I have linked them together with wires: RX on port 0 goes to TX on port 1, port 0 TX goes to port 1 RX.

I can open two terminals and send text from port 0 to port 1 or viceversa with minicom or any other terminal utility.

Now, if I want to snif on this link I can do the following: first I create a couple of virtual serial ports and link them to my real ports:

$ sudo socat -d -d pty,link=/dev/ttyUSB0,raw,echo=0 pty,link=/dev/ttyUSB1,raw,echo=0

This is the output I get (note the names of the virtual devices created):

2019/07/23 08:23:32 socat[10743] N PTY is /dev/pts/1
2019/07/23 08:23:32 socat[10743] N PTY is /dev/pts/2
2019/07/23 08:23:32 socat[10743] N starting data transfer loop with FDs [5,5] and [7,7]

And then I can run interceptty on a third terminal:

$sudo interceptty -s 'ispeed 9600 ospeed 9600' /dev/pts/2  /dev/ttyUSB1

I will now see all data traveling on the bus. This is an example of what I capture writing on port 0 and port 1 with minicom:

>       0x48 (H)
>       0x65 (e)
>       0x6c (l)
>       0x6c (l)
>       0x6f (o)
>       0x2c (,)
>       0x20
>       0x74 (t)
>       0x68 (h)
>       0x69 (i)
>       0x73 (s)
>       0x20
>       0x69 (i)
>       0x73 (s)
>       0x20
>       0x61 (a)
>       0x20
>       0x74 (t)
>       0x65 (e)
>       0x73 (s)
>       0x74 (t)
>       0x20
>       0x66 (f)
>       0x72 (r)
>       0x6f (o)
>       0x6d (m)
>       0x20
>       0x55 (U)
>       0x53 (S)
>       0x42 (B)
>       0x30 (0)
< 0x41 (A)
< 0x6e (n)
< 0x64 (d)
< 0x20
< 0x6e (n)
< 0x6f (o)
< 0x77 (w)
< 0x20
< 0x66 (f)
< 0x72 (r)
< 0x6f (o)
< 0x6d (m)
< 0x20
< 0x55 (U)
< 0x53 (S)
< 0x42 (B)
< 0x31 (1)

For your particular case, you only have one port on your computer, so you can create the virtual port pair with just one link:

$ sudo socat -d -d pty,link=/dev/ttyUSB0,raw,echo=0 pty,raw,echo=0

And run two sessions of interceptty:

$ sudo interceptty -s 'ispeed 9600 ospeed 9600' /dev/pts/1 /dev/ttyUSB0
$ sudo interceptty -s 'ispeed 9600 ospeed 9600' /dev/pts/2 /dev/ttyUSB0

For this to work reliably, I have to run first the two instances of interceptty and then open the USB ports (in my case with minicom).

Windows users can refer here for a similar solution using Termite and com0com.

Note that these procedures only work if you don't have hardware flow control active.

Marcos G.
  • 3,371
  • 2
  • 8
  • 16
  • I tried this and connecting the coolterm software but it didn't work to output any serial communication as it seems that the coolterm software cant connect through the virtual port? Is there a way with socat or interceptty to clone the throughput of /dev/ttyUSB0 to another terminal or output file? – evan Jul 23 '19 at 13:58
  • You should be able to point Coolterm to the real USB port. In the case above I was connecting to USB0 and 1 with minicom. – Marcos G. Jul 23 '19 at 14:07
  • I did it in the order you mentioned again but i get no output. the output of socat is ""socat[7933] N PTY is /dev/pts/3 socat[7933] N PTY is /dev/pts/4 socat[7933] N starting data transfer loop with FDs [5,5] and [7,7]"" I tried matching interceptty with those /dev/pts/ locations but got nothing. – evan Jul 23 '19 at 15:32
  • Strange... Have you tried with minicom and typing on the console? Or only with the final setup? This has always worked for me flawlessly. – Marcos G. Jul 23 '19 at 16:34
  • I have not used minicom. I guess that is my next step. I will update with results. – evan Jul 23 '19 at 16:52
  • Yeah, I think I'll try Coolterm myself tomorrow. If you're in a hurry you can always use the Windows solution, it works on a virtual machine too. – Marcos G. Jul 23 '19 at 17:28
  • Just so I don't leave you hanging, we moved in a different direction. No word as to why it didn't work. – evan Aug 06 '19 at 18:41
  • I'm sorry to hear that, I never had the time to check coolterm myself. Thanks for the update though. – Marcos G. Aug 06 '19 at 18:51