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


                  Hello everyone, I got the same problem as mikec156. But i couldn't solve it by updating VS. Any suggestions on how to solve this problem?

                  Comment


                    Originally posted by Comkiled95 View Post
                    Hello everyone, I got the same problem as mikec156. But i couldn't solve it by updating VS. Any suggestions on how to solve this problem?
                    Are you trying to use it on a code project or Blueprint only? If blueprint only, you need the version with the binaries compiled for your UE version. Perhaps you downloaded only the source code.
                    Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                    Unreal products: Dynamic Picture Frames, Neo Kinect

                    Comment


                      RVillani i used UE4duino plugin i just wanna ask that if i need to move a third person character do i have to do coding at both ends or just open the port ? like i really dont understand how to move a third person character should i code in arduino IDE or inside unreal engine character blueprint or inside level blueprint ?

                      Comment


                        Hey Guys,
                        I'm Using the Plugin With UE 4.21.2. It all works fine in the Editor. But after Packaging the Project the .exe wont start.

                        I think i did every kind of solution wirtten here....

                        Is there anything to add?

                        While Packaging i get those Warnings ( see Images)

                        Thanks a Lot!

                        Comment


                          Originally posted by Ahmedck View Post
                          RVillani i used UE4duino plugin i just wanna ask that if i need to move a third person character do i have to do coding at both ends or just open the port ? like i really dont understand how to move a third person character should i code in arduino IDE or inside unreal engine character blueprint or inside level blueprint ?
                          The only logic you should do in Arduino is to send input to the PC. Think of it as if you were creating a generic controller to use in any game. It should output things like "analogX=-0.5; analogY=0.23".

                          Then, in Unreal, you code to make it understand that "controller" input. I'd do that in a Blueprint that doesn't need to know about your specific character. It just outputs the inputs from Arduino. That way, you could use that Blueprint for any project with your custom Arduino controller.

                          Then, after that is set up, you create a GameMode Blueprint, a PlayerController Blueprint and a Character/Pawn Blueprint.
                          Make the GameMode's default classes be your custom PlayerController and Character Blueprints. Then, on your PlayerController, you use the inputs Blueprint to send commands to your Character Blueprint. Your Character Blueprint will have functions like "MoveForward", "Jump" etc, and the Player Controller calls those functions on it when the correct inputs come from the Arduino Blueprint. This way, your Character is not tied to one specific type of control, only your PlayerController is. And your PlayerController could be replaced by another one that controls your Character using different inputs. Or even control more Characters via possession/unpossession.

                          That's why there's this pattern of GameMode, PlayerController and Pawn in Unreal. To make things independent of each other and easily reusable.

                          If you don't care about being organized, you could just make everything I just said in the Character Blueprint, but if you'd like to reuse it some day on another project, with a totally different character, you will curse your past self for it haha
                          Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                          Unreal products: Dynamic Picture Frames, Neo Kinect

                          Comment


                            Originally posted by HysiK View Post
                            Hi all UE4Duino users and really thanks for your great work [MENTION=30654]RVillani[/MENTION] .
                            I am testing some arduino + blueprint codes without success so far and I kindly ask for help.
                            [ATTACH=CONFIG]152467[/ATTACH][ATTACH=CONFIG]152468[/ATTACH]
                            Those images are my Arduino code and my blueprint code, I do not know what I am doing wrong my main goal is sending from UE4 string ON to Arduino and Arduino must read it and activate 2 digital pins.
                            EDIT: LogTemp:Error: Failed to open port COM3. Error: 00000006 this is what I have achieved, COM port is not opening neither working. Have tried so far, 3 differents usb ports + hub (2 ad 3.0).
                            Any help? Really thanks and best regards!
                            Have you checked if you use the right port inside your device manager? arduino tools port? your timeout time is 5 (seems short to me). Have you printed something succesfully inside the arduin API with the serial plotter? I use this:
                            void loop(){


                            #define RELAY1 6

                            #define RELAY2 7

                            #define RELAY3 8

                            #define RELAY4 9

                            long mydata = 0;




                            void setup()

                            {

                            // Initialise the Arduino data pins for OUTPUT

                            Serial.begin(2400);
                            Serial.setTimeout(10);

                            pinMode(RELAY1, OUTPUT);

                            pinMode(RELAY2, OUTPUT);

                            pinMode(RELAY3, OUTPUT);

                            pinMode(RELAY4, OUTPUT);

                            }



                            void loop(){

                            while (Serial.available() == 0) {}
                            mydata = Serial.parseInt();
                            if (mydata == 10){digitalWrite(RELAY1,LOW);}
                            if (mydata == 11){digitalWrite(RELAY1,HIGH);}
                            if (mydata == 20){digitalWrite(RELAY2,LOW);}
                            if (mydata == 21){digitalWrite(RELAY2,HIGH);}
                            if (mydata == 30){digitalWrite(RELAY3,LOW);}
                            if (mydata == 31){digitalWrite(RELAY3,HIGH);}
                            if (mydata == 40){digitalWrite(RELAY4,LOW);}
                            if (mydata == 41){digitalWrite(RELAY4,HIGH);}
                            }


                            Trying to help (I am not a specialist), so Hope it helps

                            Greatings Games_master_jodan
                            Last edited by game_master_jodan; 02-07-2020, 07:36 PM.

                            Comment


                              Ok Ok. I had a hard time getting this plugin to work in a final build. But I did it and now I want to help.

                              Here is MY step by step succes formula:

                              Have the right visiual studio installed!

                              1. Download the plugin (for your Ue4 version).
                              2. Make a plugins folder inside your project.
                              3. Place the plugin inside the plugins folder of your project.
                              4. Start your project.
                              5. Activate your plugin in the edit/plugins window.
                              6. restart UE4
                              7. Make something usefull with the plugin as shown in previous posts. Dont forget to close the port on endgame!!
                              8. Go to edit/plugins ue4duino, You should see a package button.
                              9. Package the plugin inside your ENGINE/plugins folder (this is somehow needed to get the versions matching (took me ages to get this right)).
                              10. I repeat!! The plugin is now in your engine folder. The folder were your engine is installed (not your project folder).
                              11. Delete the plugin inside your projects folder. Else you get same key stuff errors when building.
                              12. Start Ue4, everything should work fine now with the plugin inside your engine folder.
                              13. Package,Cook, build, compile or use pak files (no clue what all these words mean)
                              14. Forget 13. just Package for win 64 developemen dont use pak files (you want to check something)
                              15. You endup with a WindowsNoEditor/Engine/Plugins/Ue4Duino/UE4Duino.Uplgin file

                              Double click "projectname"/Saved/StagedBuids/WindowsNoEditor/"Your project-shortcut"

                              Now everything should work!

                              I am not a coder so maybe I talk out of my ...

                              Please correct me when wrong!

                              Hope it helps someone.

                              Greetings Games_master_Jodan.
                              Last edited by game_master_jodan; 02-09-2020, 09:06 AM.

                              Comment


                                Ahmedck Comkiled95 faos1970 Guys, the forums are bugged and I can't see your DMs. It looks like you can't see mine as well.
                                So please, if it's not something private, send your messages here. You'll also help others with the same questions.
                                Otherwise you can send-me an e-mail here
                                Freelancer Game Dev Generalist and Unreal Consultant | Portfolio
                                Unreal products: Dynamic Picture Frames, Neo Kinect

                                Comment

                                Working...
                                X