Adam Shapiro
27-01-2003, 10:01
I seem to be getting very weird serial input for Dashboard3D. For example, when the robot/control board is not on/connected, I get 48 for the packet number, 176 for p2wheel, 48 for ctrl-A, etc. I don't understand... Also, when everything is connected and running, I seem to get very odd numbers. I might be doing something wrong but I don't know...
Here is the serial init code (keep in mind that it is in a bool function in a class structure):
HANDLE hfSerial;
COMMTIMEOUTS m_CommTimeouts;
hfSerial=CreateFile(Comm,GENERIC_READ,0,0,OPEN_EXI STING,FILE_ATTRIBUTE_NORMAL,0);
if(hfSerial==INVALID_HANDLE_VALUE)
{
if(GetLastError()==ERROR_FILE_NOT_FOUND){return false;}
}
SetupComm(hfSerial,128,128);
DCB dcbSerialParams;
ZeroMemory(&dcbSerialParams,sizeof(dcbSerialParams));
dcbSerialParams.DCBlength=sizeof(dcbSerialParams);
if(!GetCommState(hfSerial,&dcbSerialParams))return false;
dcbSerialParams.BaudRate=CBR_19200;
dcbSerialParams.ByteSize=8;
dcbSerialParams.StopBits=ONESTOPBIT;
dcbSerialParams.Parity=NOPARITY;
if(!SetCommState(hfSerial,&dcbSerialParams))return false;
if(!GetCommTimeouts(hfSerial, &m_CommTimeouts))return false;
m_CommTimeouts.ReadIntervalTimeout = 50;
m_CommTimeouts.ReadTotalTimeoutConstant = 50;
m_CommTimeouts.ReadTotalTimeoutMultiplier = 10;
m_CommTimeouts.WriteTotalTimeoutConstant = 50;
m_CommTimeouts.WriteTotalTimeoutMultiplier = 10;
if(!SetCommTimeouts(hfSerial, &m_CommTimeouts))return false;
hSerial=hfSerial;
strcpy(cComm,Comm);
bConnected=true;
_beginthread(SerialThread,0,NULL);
return true;
Here is the serial init code (keep in mind that it is in a bool function in a class structure):
HANDLE hfSerial;
COMMTIMEOUTS m_CommTimeouts;
hfSerial=CreateFile(Comm,GENERIC_READ,0,0,OPEN_EXI STING,FILE_ATTRIBUTE_NORMAL,0);
if(hfSerial==INVALID_HANDLE_VALUE)
{
if(GetLastError()==ERROR_FILE_NOT_FOUND){return false;}
}
SetupComm(hfSerial,128,128);
DCB dcbSerialParams;
ZeroMemory(&dcbSerialParams,sizeof(dcbSerialParams));
dcbSerialParams.DCBlength=sizeof(dcbSerialParams);
if(!GetCommState(hfSerial,&dcbSerialParams))return false;
dcbSerialParams.BaudRate=CBR_19200;
dcbSerialParams.ByteSize=8;
dcbSerialParams.StopBits=ONESTOPBIT;
dcbSerialParams.Parity=NOPARITY;
if(!SetCommState(hfSerial,&dcbSerialParams))return false;
if(!GetCommTimeouts(hfSerial, &m_CommTimeouts))return false;
m_CommTimeouts.ReadIntervalTimeout = 50;
m_CommTimeouts.ReadTotalTimeoutConstant = 50;
m_CommTimeouts.ReadTotalTimeoutMultiplier = 10;
m_CommTimeouts.WriteTotalTimeoutConstant = 50;
m_CommTimeouts.WriteTotalTimeoutMultiplier = 10;
if(!SetCommTimeouts(hfSerial, &m_CommTimeouts))return false;
hSerial=hfSerial;
strcpy(cComm,Comm);
bConnected=true;
_beginthread(SerialThread,0,NULL);
return true;