Download

How to read line from serial port using c++

Hi, I want to read data line by line from arduino on ue4 then found some code: SerialLib.h
I’m using this lib on Actor like:

char incomingData[16] = “”;
int dataLength = 16;
void ASerialReceiver::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
SerialReceiver serial;
serial.openSerialConnection(“COM3”);
serial.ReadData(incomingData, dataLength);
UE_LOG(LogTemp, Warning, TEXT("%s"), incomingData);
}
but nothing on logs, I tried to include boost lib to working with serial, but it didn’t work. Maybe there are some tutorials about reading data from serial? Also I used UE4Duino plugin, but readline function works so slowly.

You really want the serial port initialise code in BeginPlay not Tick. You need to set other params like baud rate etc too.
Having said that I use Cluster Communication Port in Code Plugins - UE Marketplace which works well for me but I only use it to send data.