RVillani / UE4Duino

Unreal Engine 4 plugin for COM communication on Windows
MIT License
287 stars 73 forks source link

Failed to setup port COM3. Error: 00000006 #28

Closed jemishGhoghari closed 1 year ago

jemishGhoghari commented 1 year ago

Hello @RVillani

When I am using this Plugin directly in a c++ class, It does not work and gives an error "Failed to open Port", But if I use in Blueprint, It's working fine! Can you help me to solve this Error? I tried to build exact logic from Blueprint to C++ code!

I attached code below! Textdokument (neu) (2).txt

RVillani commented 1 year ago

That's a C++ syntax issue you're having. Two, actually.

First, here:

USerial* new_serial; // Create a pointer variable that points to nothing yet
Serial_Port = new_serial->OpenComPort(...); // Try to call function on variable that points to nothing

This is likely where you're getting a crash from, because you're trying to access an invalid address.

Second, USerial::OpenComPort is a static function. So you don't need an instance of USerial to use it.

Serial_Port = USerial::OpenComPort(...); // Call static function from class
jemishGhoghari commented 1 year ago

Hi @RVillani

I solved the problem with your solution! Thank you! Now, It's working correctly without errors!

VG Jemish