Machsupport Forum
Mach Discussion => Mach SDK plugin questions and answers. => Topic started by: RegeG on May 27, 2013, 11:56:07 AM
-
I can start a thread and output serial data constantly without problems.
As soon as I do a serialPort->ReadByte() or serialPort->Read(buf, 0, 1) - I get an error on start up of Mach. It's "Art Code: 8877".
I've tried it both with blocking reads and with a timeout.
Anybody have any insights on "Art Code 8877"?
Thanks
-
I'd still like to understand what's going on - but I've worked around it in a slightly more processor intensive way.
Instead of blocking on the read, I did the following.......
void ReadSomeBytes(array<unsigned char>^ buffer, UInt16 offset, UInt16 count)
{
while ((MG::thcData.thcSerial->BytesToRead < count))
{
// Kill the thread if requested.
if (MG::thcControl.hariKari)
ExitThread(0);
// Didn't get killed, so sleep a little
Sleep(5);
}
// Read the bytes.
MG::thcData.thcSerial->Read(buffer, offset, count);
}
("hariKari" is a boolean flag that the plug-in uses to signal the serial input processing thread to gracefully shut down.)