
DWORD SerialReadThread(LPVOID lpvoid)
{
// Specify a set of events to be monitored for the port.
SetCommMask (SerialChannel, EV_RXCHAR);
while (SerialChannel != INVALID_HANDLE_VALUE)
{
DWORD CommStatus;
// Wait for an event to occur for the port.
WaitCommEvent (SerialChannel, &CommStatus, 0);
// Re-specify the set of events to be monitored for the port.
SetCommMask (SerialChannel, EV_RXCHAR);
if (CommStatus & EV_RXCHAR)
{
DWORD BytesTransferred;
// Loop for waiting for the data.
do
{
BYTE Byte;
// Read the data from the serial port.
ReadFile (SerialChannel, &Byte, 1,
&BytesTransferred, 0);
// Display the data read.
if (BytesTransferred == 1)
{
ProcessSerialChar(Byte);
}
}
while (BytesTransferred == 1);
}
}
return 0;
}
// --------------------------------------------------------------------------------------
int OpenPort(HWND ParentWindowHandle)
{
DWORD dwError;
DCB PortDCB;
COMMTIMEOUTS Timeouts;
DWORD ThreadID;
SerialChannel = CreateFile (SERIAL_PORT, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
// If it fails to open the port, return FALSE.
if (SerialChannel == INVALID_HANDLE_VALUE )
{
// Could not open the port.
MessageBox (ParentWindowHandle, TEXT("Unable to open the serial port"),
ERROR_TEXT, MB_OK);
dwError = GetLastError ();
return FALSE;
}
PortDCB.DCBlength = sizeof(DCB);
// Get the default port setting information.
GetCommState (SerialChannel, &PortDCB);
// Change the DCB structure settings.
PortDCB.BaudRate = 115200;
// Current baud
PortDCB.fBinary = TRUE;
// Binary mode; no EOF check
Содержание Pro60
Страница 1: ...Blackroc Pro60 Thermal Printer Programming Manual March 2007 V1 4 ...
Страница 21: ...DeleteObject BitmapHandle return TRUE ...
Страница 24: ...Windows Mobile 2003 ...
Страница 25: ......
Страница 26: ...Alphabetical Index ...