Skip to content

Commit

Permalink
Fix crash when ReadLine is used and there's no data to read.
Browse files Browse the repository at this point in the history
  • Loading branch information
RVillani committed Jun 27, 2017
1 parent 83aa65d commit 937621b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions UE4Duino/Source/UE4Duino/Private/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ FString USerial::ReadStringUntil(bool &bSuccess, uint8 Terminator)
{
// when Terminator is \n, we know we're expecting lines from Arduino. But those
// are ended in \r\n. That means that if we found the line Terminator (\n), our previous
// character was \r, so we remove that from the array.
if (Terminator == '\n' && Chars.Top() == '\r') Chars.Pop(false);
// character could be \r. If it is, we remove that from the array.
if (Chars.Num() > 0 && Terminator == '\n' && Chars.Top() == '\r') Chars.Pop(false);

Chars.Add(0x0);
break;
Expand Down
2 changes: 1 addition & 1 deletion UE4Duino/UE4Duino.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"FriendlyName": "UE4Duino",
"Version": 2,
"VersionName": "2.2.0",
"VersionName": "2.2.1",
"CreatedBy": "Rodrigo Villani",
"EngineVersion": "4.16",
"Description": "Enables communication between UE4 and COM ports",
Expand Down

2 comments on commit 937621b

@gaozefei
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your efforts. But I used this plugin (read line) , I did receive somting but there is nothing to print on the screen . My UE4 version is 4.16.2. The code of arduino is the example ,can you give me some suggest? thank you very much!

@RVillani
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! o/ I answered you on the forum. Show me your Arduino and Blueprint code there.
A mistake users make a lot is to expect to ReadLine from anything sent from Arduino. It only works if you're using the Serial.println() function in Arduino, because then Arduino sends the required /r/n at the end of the string. If you're using other methods to send data from Arduino, you have to use ReadByte(s) in Unreal or other function compatible with your Arduino data.

If you need more help, I do Unreal consulting via Skype. Find my contact info here.

Greetings, Villani.

Please sign in to comment.