tags:

views:

43

answers:

1

Hi, 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.

Cheers

+1  A: 

I would use the DataReceived event. Then inside the event handler, try and call ReadExisting. The link I posted has an example.

SwDevMan81
Unity does not allow you to use the DataReceived event