#include <serialport.h>
An example method for the use of this object follows:
BOOL TestSerialPort() { BOOL result; unsigned i; unsigned numBytesRead = 0; unsigned char buffer[8192] SERIALPORT_structObject port; result = SERIALPORT_Initialize( &port ); port.port = 1; // COM1 port.baudrate = SERIALPORT_BAUD_9600; port.parity = SERIALPORT_PARITY_NONE; port.databits = SERIALPORT_DATABITS_8; port.stopbits = SERIALPORT_STOPBITS_1; port.flowcontrol = SERIALPORT_FLOWCONTROL_NONE; port.timeout = 0; port.behaviour = SERIALPORT_BEHAVIOUR_RETURN_IMMEDIATELY; result = SERIALPORT_Open( &port ); if( !result ) return FALSE; for( i = 0; i < 100; i++ ) { result = SERIALPORT_Read( &port, buffer, 8192, numBytesRead ); if( !result ) return FALSE; if( numBytesRead > 0 ) printf( "%s\n", buffer ); Sleep(1); } sprintf( buffer, "Hello SERIALPORT\n" ); for( i = 0; i < 100; i++ ) { result = SERIALPORT_Write( &port, buffer, strlen( buffer ) ); if( !result ) return FALSE; Sleep(1); } result = SERIALPORT_Close( &port ); return TRUE; }
Definition at line 214 of file serialport.h.
Data Fields | |
| SERIALPORT_enumBaudRate | baudrate |
| The serial port baud rate [bits per second]. | |
| SERIALPORT_enumParity | parity |
| The serial port parity. | |
| SERIALPORT_enumDataBits | databits |
| The serial port data bits. | |
| SERIALPORT_enumStopBits | stopbits |
| The serial port stop bits. | |
| SERIALPORT_enumFlowControl | flowcontrol |
| The serial port flow control setting. | |
| BOOL | isPortOpen |
| A boolean to indicate if the serial port is open. | |
| unsigned short | port |
| The serial port number. A value greater than 0. | |
| unsigned int | timeout |
| The serial port timeout value [ms]. Not used if behaviour == SERIALPORT_BEHAVIOUR_RETURN_IMMEDIATELY. | |
| HANDLE | handle |
| A windows handle for the serial port. | |
| SERIALPORT_enumBehaviour | behaviour |
| The serial port behaviour during read operationss. | |
| DCB | control_setting |
| The control settings for a windows serial communications device. Do not alter the members of the control settings. This is done internally only. | |
| unsigned short SERIALPORT_structObject::port |
| unsigned int SERIALPORT_structObject::timeout |
The serial port timeout value [ms]. Not used if behaviour == SERIALPORT_BEHAVIOUR_RETURN_IMMEDIATELY.
Definition at line 225 of file serialport.h.
The control settings for a windows serial communications device. Do not alter the members of the control settings. This is done internally only.
Definition at line 232 of file serialport.h.