I have hooked a Unity project up to an Arduino board via a com port. I am receiving data from it fine while using SerialPort.ReadLine(), however, if i use SerialPort.ReadExisting() I get the error:
Object reference not set to an instance of an object
I need to use ReadExisting as my application cant keep up with the rate that the Ardunio board is spitting out data.
I have got ReadExisting working fine in a XNA project, just when used in a unity project i have issues.
Any help would be highly appreciated.
I would use the DataReceived event. Then inside the event handler, try and call ReadExisting. The link I posted has an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With