socat to log serial port data - serial-port

I want to log and display a stream of data arriving at a serial port in hex with timestamps and all non printable characters (particularly any XON XOFF characters). don't need to transmit anything on the Tx port, it is not connected.
Been trying to use stty to set port parameters and socat to log but having trouble.
using /dev/null socat just exits without any doing any thing, using -u and /dev/null as second address doesn't show or log anything, using a PTY as second address works for a while but then hangs - I guess the PTY fills up and block with nothing reading it.
Thanks for any help.

Related

Qemu connecting to specific guest UART device

I emulate the firmware of a embedded device with qemu-system-arm. The output of the console is working fine by appending "console=ttyAMA0" to the kernel. On the guest there is a binary which opens another serial port for communication (bi-directional) on /dev/ttyGS0 and listens on that port. Now I need to connect to this port from the host, to send commands to the binary and receive the output.
I already tried different things like creating character devices and pseudo ttys, but I don't know how to define the serial device for the guest.
Is there a way to do this?
Thanks in advance.
If you pass multiple -serial options to QEMU they will be interpreted as defining what you want to do for UARTs 0, 1, 2, etc. So for example "-serial stdio -serial tcp::4444,server" will send UART 0 to your terminal and connect UART 1 to a TCP server on port 4444 which you can then connect to with netcat or similar utility. (You can connect serial output to a lot of different backends, not just stdio or TCP: check the QEMU documentation.)
(NB: this relies on your board model actually creating multiple UARTs and wiring them up to the command line options correctly, of course.)

BlueZ BLE GATT write request (0x12) instead of (0x16)

I am trying to reverse engineer a BLE device for research. The BLE device does not require pairing.
One of the commands that are written that I can see in wireshark is write to a specific handle. When I try to do the same using the Gatttool write request:
sudo gatttool -i hci0 -b 54:6C:0E:21:F5:99 --char-write-req -a 0x0030
-n 110100701301000110010030721000d68c054688df413aa89fb3cfab3d6457172000053958839fa147ac53c129eafc524829bc9ed7655fe96c9f641745c4e07cf044
It uses a 0x16 prepare write request instead and there seems to be some error as well. Below is an image of both captures, the left side is the GAtttool request and the right side is the request done by the phone.
The communication to the right has earlier negotiated a larger MTU. That's why it can send the whole value in one request.

Why does Plink not behave the same as PuTTY with serial connection?

I am trying to programmatically communicate with a device connected over a serial connection. When I send commands using PuTTY, I have no problems. But when I try to communicate using Plink, I get no response. What would cause that difference?
I connect to PuTTY through the command line using putty -serial com3 -sercfg 9600 and then send my commands from within the PuTTY window using Ctrl-J (to adjust for the line endings, I think? It works in any case).
And I connect to plink using plink -serial com3 -sercfg 9600, but then neither enter nor Ctrl-J or any combination seem to send my commands.

Use tty to pass serial data - communication between host & guest

I'm using QEMU and here is my problem : I want to send basic data from host to guest.
I first tried using virtio-serial, but I can't modify my guest kernel (2.6.32) => virtio-console wasn't made to support the virtio-serial communication.
I can't use USB nor TCP:IP... Yes it's painful.
I thought about using the TTY on my guest, then connected to my host using chardevs :
qemu-system-i386 image.raw -chardev socket,path=mysock,server,nowait,id=sok -serial pty -serial chardev:sok -nographic
That works almost as intended... Problem, the data isn't sent to the guest through my socket until I enter a '\r' (new line), which corresponds to a 0xA in hexa. And some of my data can take this value !
Is there a way to configure a tty so it doesn't recognize some characters as options ? Or better : a simple way to send data host <=> guest

how to send data in ping program

I wanted to send data to the loop-back IP address 127.0.0.1 using the ping program.
$ping 127.0.0.1 "my data" and wanted to see it in the kernel space.
if anyone has some idea please respond to me
Use ping's -p option:
-p pattern
You may specify up to 16 ``pad'' bytes to fill out the packet you send.
This is useful for diagnosing data-dependent problems in a network.
For example, -p ff will cause the sent packet to be filled with all ones.

Resources