relativty / wrmhl

(Archived) Simple communication between Unity3D and Arduino - by Maxim xyz.
MIT License
643 stars 63 forks source link

Null error after one successful sensorRead #8

Open dilanshah opened 6 years ago

dilanshah commented 6 years ago

My system details: image

image

Serial monitor shows normal function: image

I closed arduino and serial monitor

Works for the first couple, but then null:

image The issue is on this line:

image

I'm preparing a biology experiment where the communication would be very useful. How do I remedy this? thanks so much! -Brian

dilanshah commented 6 years ago

@bc

bc commented 6 years ago

I can prevent these issues by by restarting the computer. If the SerialMonitor is opened at any time, even after closing it there are permission errors in Unity. Why is this?

SHANTANUB009 commented 6 years ago

I am also getting same kind of result like, I am uploading the code to Arduino. Then I run the unity file. It reads the thread perfectly and gives me data.

Then when I disconnect the arduino from Port and reconnect it, run the unity file , it throws this NULL value.

cptdustmite commented 6 years ago

I am also getting this null value, with a simple program similar to the above.

This worked fine with one of my boards, and then after switching to a much faster Teensy 3,2 board it now returns Null only (with one Hello World getting in).

cptdustmite commented 6 years ago

I found out that I can get it almost working if I introduce a delay in my Arduino code at the end of the loop.

Tested with various combinations of Arduino delay and wrmhl readTimeout, the best combination is delay of 5 in Arduino and readTimeout of 25 in wrmhl. This returns all values properly except for the very first one which is Null.

maxim-perumal commented 6 years ago

Thanks for the contribution, I will investigate the issue ! I close the issue for the moment but feel free to re-open any time !

lordton commented 5 years ago

Same problem here :(

lordton commented 5 years ago

Changing baudrate, timeouts of arduino and unity does change things a little. Sometimes you can get 3-4 successful reads before NULLs.

Also i have noticed that if you start Arduino IDE serial monitor, then close it, then play the Unity project, you get the first readings. If then you stop unity and play again, you get NULLs straight away. If you stop again, run Arduino IDE serial monitor, close it and then replay Unity project, then again you get the first readings.

I'm running a clone Arduino Nano on OsX High Sierra and Unity 2018.1.6f1 . I guess i should try another board or windows, but don't have them at the moment.

Please help 🙏