UPDATE!
UE4Duino 2.0
First of all, thanks a lot to @ for saving me time on understanding how to use serial ports on C++ in Windows!
I’ve rewritten the plugin from ground up, but wanted to keep 's credits for the name and his initiative.
The zip below contains binaries for UE 4.14.0, but it should compile successfully since 4.11. Maybe even lower.
Download:
Attention: if updating it on an existing project, beware! You’ll need to change some stuff as it now works on instanced variables instead of a static connection.
USAGE
- You can use the Construct Object From Class node to create an instance of the Serial class and use the Open COM function to start the connection.
- Or you can use the static function Open COM Port, which will create the instance and open the port for you. Just remember to store that instance in some variable to use later!
- ALWAYS call Close COM before quitting the game (like on Event End Play). If you fail to do so, you won’t be able to reopen it unless you reconnect the device to the PC.
- For now, you have to check for input on Tick. Whatever kind of input you read for, it’ll return Success=true if there was input. But I intend to create a thread just for checking and notifying input changes with events.
CHANGE LOG
- Code is more Unrealish: hide windows platform types; switch from TCHAR] to FString; use *FMemory *methods; *int32 *instead of int; *bool *instead of *BOOL *etc.
- Works with COM10 and above. (If you change your COM to test it, you need to reconnect the device).
- Condensed everything into a single class: Serial.
- Not threaded. Reading when there’s no data to read will return instantly. When reading serial inside Arduino code, remember to use Serial.setTimeout(10) on the setup function, so the Serial.readStringUntil (and other functions that interpret a group of bytes) return faster.
- Added functions to read and write numeric data types (float, int, *byte *and byte array). On the Arduino side you must know how to convert byte arrays from/to these types.
- Added ability to read Strings by line or whole string found in serial.
- Added ability to work with more than one Arduino (COM) simultaneously. The class works with instanced objects instead of static variables.
- It packages successfully (tested on Development and Shipping modes).
- Changed logo and “Creator” on plugin description as I mostly rewrote it. But kept the name as it’s very nice and @ deserves its credits for starting the thing. Hoping he won’t mind much.
[/QUOTE]
Hi, RVillani, thank you so much for your work! I’ve been successfully using your previous plugin on 4.10 version. It works great and it is really helpful!
Now I have new challenge - I have to filter input signal (I have C++ code for the filter) however I don’t understand how I can implement it in this plugin. I started learning how to program C++ in UE4 but I still don’t see a link between your amazing plugin in blueprints and C++ class. Do you have any ideas how this can be done?