Announcement

Collapse
No announcement yet.

[Free][Windows only] UE4Duino 2 - Arduino (COM port) communication

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hi,
    Is there a way to check how many bytes of data are available in the serial buffer to be read? Let's say I have sent a float data (4 bytes) from the arduino to UE4, I would like to have my program on UE4 to keep checking the buffer until there are 4 bytes before reading it. Is there also a "read a specified number of bytes" function that would block until the specified amount of bytes has been read?
    Thank you.

    Comment


      Click image for larger version  Name:	PluginError.jpg Views:	0 Size:	22.4 KB ID:	1683724
      I get the above error after I restart UE 4.23.1 after activating the plugin. (Win 10)
      I have tried copying the UE4Duino folder to the Engine Plugins page as well as the Projects plugin page, redownloading etc.
      Any help would be appreciated.
      Thanks

      Solved: Deleting binaries and Intermediate folders and rebuilding fixed it.
      Last edited by Hrishi_A; 11-07-2019, 02:14 PM.

      Comment


        Originally posted by DoktorDangerous View Post
        Hi,
        Is there a way to check how many bytes of data are available in the serial buffer to be read? Let's say I have sent a float data (4 bytes) from the arduino to UE4, I would like to have my program on UE4 to keep checking the buffer until there are 4 bytes before reading it. Is there also a "read a specified number of bytes" function that would block until the specified amount of bytes has been read?
        Thank you.
        There's no function to read the number of bytes in the serial connection nor one that blocks until a number is read. In fact, I'd never do anything that blocks unreal intentionally, as it sounds like bad design.
        In your case I'd simply keep reading bytes from the serial with ReadBytes and storing them in an array until the array has 4 bytes. Then I'd use those 4 to make a float and clear the array. But if you're trying to do that as a way to avoid getting split bytes from Arduino (like the last 2 from a float and the first 2 from another one), that wouldn't solve it, because you could be splitting since the first time you called the function. You need to come up with a way to signal Unreal when you are going to send another float. In this thread, if you search for protocol, there's a post where I describe how I overcome this type of problem with a protocol (like a router's handshake).
        Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
        Unreal products: Dynamic Picture Frames, Neo Kinect

        Comment


          If after you have built your app and the program refuses to run and in your log file you see the line

          Code:
          LogPluginManager: Error: Unable to load plugin 'UE4Duino'. Aborting.
          Make sure that you have

          Code:
          "Installed": true,
          in your UE4Duino.uplugin file.

          Comment


            Hi,

            I'm using the UE4Duino for the first time and i'm having sync problems betwee the arduino output and the UE4 input read..

            I believe that i have read most of the posts regarding this issue.
            So i'm cheking the incoming string with a prefix and suffix.
            but what i notice is that only if the incoming string is 8 characters long, i get a stable input. e.g. the prefix and suffix check results in true
            Smaller or bigger length strings, result in fewer incoming strings passing the prefix and suffix check.

            any idea why this could be?

            Comment


              Originally posted by Jos_._G View Post
              Hi,

              I'm using the UE4Duino for the first time and i'm having sync problems betwee the arduino output and the UE4 input read..

              I believe that i have read most of the posts regarding this issue.
              So i'm cheking the incoming string with a prefix and suffix.
              but what i notice is that only if the incoming string is 8 characters long, i get a stable input. e.g. the prefix and suffix check results in true
              Smaller or bigger length strings, result in fewer incoming strings passing the prefix and suffix check.

              any idea why this could be?
              It's what you said. A sync issue. Unless you are losing data in between strings, than that's another issue that I haven't seen.
              Try appending the strings you get from Arduino to each other, until you have the complete "phrase". It's common to get them in pieces, because of the sync issues. Unreal can be reading before Arduino has finished writing. So append, wait for next read, append again and check for the prefix/suffix. Once you find those, remove what's before the suffix and keep appending next reads to the string. That way, your string variable will be like a buffer that you remove completed strings from.

              And never use Flush! Read until there's nothing to read. Flush will empty the serial and delete strings you had yet to read.
              Actually, just flush once when you open the comms with Arduino, to clear previously accumulated unread data in the serial, before you start reading.
              Last edited by RVillani; 12-18-2019, 02:06 PM.
              Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
              Unreal products: Dynamic Picture Frames, Neo Kinect

              Comment


                I'm getting this message
                Click image for larger version  Name:	UE4Duino-error.JPG Views:	2 Size:	20.0 KB ID:	1703531

                Fixed it. I should have read earlier, but it is important to have the latest VS version installed (free community version).
                Last edited by mikec156; 01-02-2020, 11:54 PM.

                Comment

                Working...
                X