Serial UART BUS Signal to serial Monitor -MLINK RC radio system

Hello,
To control my RC Planes I use a Multiplex MLINK 2,4GHz transmitter System. This System sends telemetry data with the “MSB” serial BUS from receiver to transmitter and provides that data on a COM port at the transmitter.
The interface parameters of the serial stream are known. (38400, n, 8, 1 single wire half duplex).
A packet should contain 20byte. STX is 0x02 and ETX is 0x03. Between these two bytes, telemetry information can be found in the other 18 bytes. To get these information I have to take care of nibbles, LSB, MSB, byte stuffing etc.. but all these Information is known.
Later on, I want to use a Arduino nano, for testing I use Arduino Uno. (one serial port)
First I want to send the raw byte stream to the serial monitor. (COM port has three pins. Signal/GND/Vcc)
Therefor I connect the signal Pin to RX and ground to GND. Boudrate is 38400.
My code, just to transfer the stream to serial monitor:

void setup() {
  Serial.begin(38400);
}
void loop() {
  if (Serial.available() > 0)
     {Serial.print(Serial.read(),HEX);
     Serial.print(" ");
     }
  }

My result:

20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C
20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28 20 A0 3C 3B F3 20 30 28

The data stream should look like this:
0x02 0x00 0x30 0x34 0x31 0x00 0x1B 0x22 0x22 0x06 0x1A 0xC8 0x00 0x38 0x1B 0x1B 0x23 0x3B 0x7E 0x03
Or:
02 00 30 34 32 22 1B 22 22 06 1A C8 00 38 1B 23 3B 7E 03 02 00 30 34 32 22 1B 22 22 06 1A C8 00 38 1B 23 3B 7E 03…..

My stream is definitely to short and there are no 02 or 03 bytes!! Maybe I did something wrong in my code. I use the same serial port to receive and transmit to the computer. Maybe this is the problem.
Can you tell me how I can receive a serial Hex signal on any Arduino UNO Pin and plot it to the serial monitor at once?
Just like a logic analyser I want to Display the RAW data stream of Hex numbers.

Greetings
Roland

Can you tell me how I can receive a serial Hex signal on any Arduino UNO Pin and plot it to the serial monitor at once?

Using a device with one hardware serial port? You can't. Use a Mega.

It would certainly make a lot more sense to use a Mega (or Leonardo or Micro) at least in the test and development phase.

I think the data stream that you describe can easily be captured by the 3rd example in Serial Input Basics. There is also a parse example.

...R

I think the other replies are missing the point; OP states that it is for testing purposes. TX of a device connected to RX of Arduino (pin 0). TX of Arduino connected to computer (via USB).

Should work if the device's TX is TTL level.

OP: what is that COM port that you're talking about? TTL interface, RS232 interface. If that is an interface to a PC, it will be RS232 and the levels will be wrong and they will be inverted.

Hi,
the COM port is normal UART (TTL). The Multiplex MSB protocol is straight forward semi-duplex 38.4kbps (one-wire) at 3.3V Byte structure 10-bit 0xx1, where x = nibble (4 bits), LSB first.

MGEA, Teensy etc is no option! I want to use an Arduino UNO/mini/nano. For Teensy with three serial UARTS I have a Sketch for a functional converter from this MSB to another RC System, but that doesnt help, becouse the UNO does only have ONE serial port.

With an TTl to USB cable it shoud be possible to display the stream on a PC, but first I dont know what Software I could use therefore and secoundly I would like to use an Arduino therefore.

I will take a look at the Serial Input Basic example.

If you have to use an Uno one option may be to use HardwareSerial for receiving the data (at 38400 baud) and use SoftwareSerial (at 9600 baud) and a USB-ttl converter to pass the data to a PC.

I don’t think SoftwareSerial will work reliably at 38400 baud.

…R

Use AltSoftSerial on pins 8 & 9:

#include <AltSoftSerial.h>

AltSoftSerial mlink;

void setup() {
  Serial.begin(115200); // faster!  Change in the Serial Monitor window, too.
  mlink.begin( 38400 );
}

void loop() {
  while (mlink.available()) {
    Serial.print( mlink.read(), HEX );
    Serial.print( ' ' );
  }
}

If those pins aren’t available, use NeoSWSerial. Don’t use SoftwareSerial, it’s very inefficient.

Bump the Serial rate because for every one character you receive from the MLINK, you are sending three to Serial for debugging. Because 115200 is exactly 3 * 38400, loop() may eventually block while printing, and then you will start losing MLINK data (input buffer overflow). That could happen very quickly (if the 38400 is actually a little faster) or never (if the 38400 is actually a little slower). Just try it.

PaulS:

Donaufisch:
Can you tell me how I can receive a serial Hex signal on any Arduino UNO Pin and plot it to the serial monitor at once?

You can’t.

?

Robin2:
I don’t think SoftwareSerial will work reliably at 38400 baud.

?? All software serial libraries will work at that baud rate: AltSoftSerial, NeoSWSerial and even SoftwareSerial.

Cheers,
/dev

Donaufisch:
With an TTl to USB cable it shoud be possible to display the stream on a PC, but first I dont know what Software I could use therefore and secoundly I would like to use an Arduino therefore.

You an use RealTerm; it has the option to display HEX.

Donaufisch:
I will take a look at the Serial Input Basic example.

It will not help if you currently don't get the correct data. Once you're current code gives the expected data, you can apply the principles of the Serial Input Basics thread.