so if you were to connect the Arduino Rx to the PC's Serial adaptor and the Arduino Tx to the "unconventional hardware's serial port Rx" then you would have a "man in the middle" sniffing what's going on. this would work on a Mac or PC or whatever appears as an UART running at 9600 bauds, 8N1.
Here I made the bytes being displayed on an LCD screen in a pretty crude way since it's scrolling so you can only see the last 4 bytes, not very useful but just a proof of concept
click to see the code
/* ============================================
code is placed under the MIT license
Copyright (c) 2025 J-M-L
For the Arduino Forum : https://forum.arduino.cc/u/j-m-l
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
const uint8_t nbCols = 20;
const uint8_t nbRows = 4;
hd44780_I2Cexp lcd;
void lcdLog(const char *format, ...) {
static char framebuffer[nbRows][nbCols + 1];
static byte currentLine = 0;
va_list args;
va_start(args, format);
if (currentLine >= nbRows) {
for (byte line = 1; line < nbRows; line++) strlcpy(framebuffer[line - 1], framebuffer[line], nbCols + 1); // shift lines up
vsnprintf(framebuffer[nbRows - 1], nbCols + 1, format, args); // add the new line
lcd.clear();
for (byte line = 0; line < nbRows; line++) {
lcd.setCursor(0, line);
lcd.print(framebuffer[line]);
}
} else {
vsnprintf(framebuffer[currentLine], nbCols + 1, format, args);
lcd.setCursor(0, currentLine);
lcd.print(framebuffer[currentLine]);
currentLine++;
}
va_end(args);
}
void setup() {
Serial.begin(9600); // 9600 bauds, 8N1
int result = lcd.begin(nbCols, nbRows);
if (result) {
Serial.print("LCD initialization failed: ");
Serial.println(result);
hd44780::fatalError(result);
}
lcd.clear();
Serial.println("OK");
}
void loop() {
if (Serial.available()) {
byte r = Serial.read();
Serial.write(r); // pass the byte down the chain
if (isprint(r)) lcdLog("Hex: %02X, char: %c", r, (char) r);
else {
switch (r) {
case 0x00: lcdLog("Hex: %02X, ctrl: NUL", r); break; // Null
case 0x01: lcdLog("Hex: %02X, ctrl: SOH", r); break; // Start of Heading
case 0x02: lcdLog("Hex: %02X, ctrl: STX", r); break; // Start of Text
case 0x03: lcdLog("Hex: %02X, ctrl: ETX", r); break; // End of Text
case 0x04: lcdLog("Hex: %02X, ctrl: EOT", r); break; // End of Transmission
case 0x05: lcdLog("Hex: %02X, ctrl: ENQ", r); break; // Enquiry
case 0x06: lcdLog("Hex: %02X, ctrl: ACK", r); break; // Acknowledge
case 0x07: lcdLog("Hex: %02X, ctrl: BEL", r); break; // Bell
case 0x08: lcdLog("Hex: %02X, ctrl: BS", r); break; // Backspace
case 0x09: lcdLog("Hex: %02X, ctrl: TAB", r); break; // Horizontal Tab
case 0x0A: lcdLog("Hex: %02X, ctrl: LF", r); break; // Line Feed
case 0x0B: lcdLog("Hex: %02X, ctrl: VT", r); break; // Vertical Tab
case 0x0C: lcdLog("Hex: %02X, ctrl: FF", r); break; // Form Feed
case 0x0D: lcdLog("Hex: %02X, ctrl: CR", r); break; // Carriage Return
case 0x0E: lcdLog("Hex: %02X, ctrl: SO", r); break; // Shift Out
case 0x0F: lcdLog("Hex: %02X, ctrl: SI", r); break; // Shift In
case 0x10: lcdLog("Hex: %02X, ctrl: DLE", r); break; // Data Link Escape
case 0x11: lcdLog("Hex: %02X, ctrl: DC1", r); break; // Device Control 1
case 0x12: lcdLog("Hex: %02X, ctrl: DC2", r); break; // Device Control 2
case 0x13: lcdLog("Hex: %02X, ctrl: DC3", r); break; // Device Control 3
case 0x14: lcdLog("Hex: %02X, ctrl: DC4", r); break; // Device Control 4
case 0x15: lcdLog("Hex: %02X, ctrl: NAK", r); break; // Negative Acknowledge
case 0x16: lcdLog("Hex: %02X, ctrl: SYN", r); break; // Synchronous Idle
case 0x17: lcdLog("Hex: %02X, ctrl: ETB", r); break; // End of Block
case 0x18: lcdLog("Hex: %02X, ctrl: CAN", r); break; // Cancel
case 0x19: lcdLog("Hex: %02X, ctrl: EM", r); break; // End of Medium
case 0x1A: lcdLog("Hex: %02X, ctrl: SUB", r); break; // Substitute
case 0x1B: lcdLog("Hex: %02X, ctrl: ESC", r); break; // Escape
case 0x1C: lcdLog("Hex: %02X, ctrl: FS", r); break; // File Separator
case 0x1D: lcdLog("Hex: %02X, ctrl: GS", r); break; // Group Separator
case 0x1E: lcdLog("Hex: %02X, ctrl: RS", r); break; // Record Separator
case 0x1F: lcdLog("Hex: %02X, ctrl: US", r); break; // Unit Separator
case 0x7F: lcdLog("Hex: %02X, ctrl: DEL", r); break; // Delete
default: lcdLog("Hex: %02X", r); break;
}
}
}
}