#include <windows.h>
Go to the source code of this file.
Defines | |
#define | RS232_BAUD_RATE_110 CBR_110 |
#define | RS232_BAUD_RATE_115200 CBR_115200 |
#define | RS232_BAUD_RATE_1200 CBR_1200 |
#define | RS232_BAUD_RATE_128000 CBR_128000 |
#define | RS232_BAUD_RATE_14400 CBR_14400 |
#define | RS232_BAUD_RATE_19200 CBR_19200 |
#define | RS232_BAUD_RATE_2400 CBR_2400 |
#define | RS232_BAUD_RATE_256000 CBR_256000 |
#define | RS232_BAUD_RATE_300 CBR_300 |
#define | RS232_BAUD_RATE_38400 CBR_38400 |
#define | RS232_BAUD_RATE_4800 CBR_4800 |
#define | RS232_BAUD_RATE_56000 CBR_56000 |
#define | RS232_BAUD_RATE_57600 CBR_57600 |
#define | RS232_BAUD_RATE_600 CBR_600 |
#define | RS232_BAUD_RATE_9600 CBR_9600 |
#define | RS232_MAX_WAIT_READ 1000 |
#define | RS232_PARITY_EVEN EVENPARITY |
#define | RS232_PARITY_MARK MARKPARITY |
#define | RS232_PARITY_NOPARITY NOPARITY |
#define | RS232_PARITY_ODD ODDPARITY |
#define | RS232_PARITY_SPACE SPACEPARITY |
#define | RS232_RX_SIZE 4096 |
#define | RS232_STOP_BIT_ONE ONESTOPBIT |
#define | RS232_STOP_BIT_ONE5 ONE5STOPBITS |
#define | RS232_STOP_BIT_TWO TWOSTOPBITS |
#define | RS232_TX_SIZE 4096 |
Functions | |
int | rs232_close () |
int | rs232_open (char *_port, int baud_rate, int byte_size, int parity, int stop_bits) |
int | rs232_read (void *buffer, int size, int *_read_bytes) |
int | rs232_write (void *buffer, int size, int *_written_bytes) |
#define RS232_BAUD_RATE_110 CBR_110 |
Definition at line 40 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_115200 CBR_115200 |
Definition at line 52 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_1200 CBR_1200 |
Definition at line 43 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_128000 CBR_128000 |
Definition at line 53 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_14400 CBR_14400 |
Definition at line 47 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_19200 CBR_19200 |
Definition at line 48 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_2400 CBR_2400 |
Definition at line 44 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_256000 CBR_256000 |
Definition at line 54 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_300 CBR_300 |
Definition at line 41 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_38400 CBR_38400 |
Definition at line 49 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_4800 CBR_4800 |
Definition at line 45 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_56000 CBR_56000 |
Definition at line 50 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_57600 CBR_57600 |
Definition at line 51 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_600 CBR_600 |
Definition at line 42 of file ADPCM_STREAMING/rs232.h.
#define RS232_BAUD_RATE_9600 CBR_9600 |
Definition at line 46 of file ADPCM_STREAMING/rs232.h.
#define RS232_MAX_WAIT_READ 1000 |
Definition at line 38 of file ADPCM_STREAMING/rs232.h.
#define RS232_PARITY_EVEN EVENPARITY |
#define RS232_PARITY_MARK MARKPARITY |
Definition at line 57 of file ADPCM_STREAMING/rs232.h.
#define RS232_PARITY_NOPARITY NOPARITY |
#define RS232_PARITY_ODD ODDPARITY |
#define RS232_PARITY_SPACE SPACEPARITY |
Definition at line 60 of file ADPCM_STREAMING/rs232.h.
#define RS232_RX_SIZE 4096 |
#define RS232_STOP_BIT_ONE ONESTOPBIT |
#define RS232_STOP_BIT_ONE5 ONE5STOPBITS |
#define RS232_STOP_BIT_TWO TWOSTOPBITS |
#define RS232_TX_SIZE 4096 |
int rs232_close | ( | ) |
Definition at line 122 of file ADPCM_STREAMING/rs232.c.
00123 { 00124 CloseHandle(handle_com); 00125 return 1; 00126 }
int rs232_open | ( | char * | _port, | |
int | baud_rate, | |||
int | byte_size, | |||
int | parity, | |||
int | stop_bits | |||
) |
Definition at line 80 of file ADPCM_STREAMING/rs232.c.
00081 { 00082 // Make sure another port is not already opened 00083 ASSERT(!handle_com); 00084 00085 // Open the existing COMX file to open the port 00086 handle_com = CreateFile( 00087 _port, 00088 GENERIC_READ | GENERIC_WRITE, 00089 0, 00090 NULL, 00091 OPEN_EXISTING, 00092 FILE_ATTRIBUTE_SYSTEM, 00093 NULL); 00094 00095 // Make sure it is opened 00096 if (handle_com == INVALID_HANDLE_VALUE) 00097 return 0; 00098 00099 // buffer size for emission and reception 00100 SetupComm(handle_com, RS232_RX_SIZE, RS232_TX_SIZE); 00101 00102 // COM port configuration 00103 g_dcb.BaudRate = baud_rate; 00104 g_dcb.ByteSize = byte_size; 00105 g_dcb.Parity = parity; 00106 g_dcb.StopBits = stop_bits; 00107 if(!SetCommTimeouts(handle_com, &g_cto) || !SetCommState(handle_com, &g_dcb)) 00108 { 00109 CloseHandle(handle_com); 00110 return 0; 00111 } 00112 00113 // Flush buffers for emission and reception 00114 // DTR = 1 00115 PurgeComm(handle_com, PURGE_TXCLEAR | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_RXABORT); 00116 EscapeCommFunction(handle_com, SETDTR); 00117 00118 return 1; 00119 }
int rs232_read | ( | void * | buffer, | |
int | size, | |||
int * | _read_bytes | |||
) |
Definition at line 129 of file ADPCM_STREAMING/rs232.c.
00130 { 00131 return ReadFile(handle_com, buffer, size, (DWORD *) _read_bytes, (LPOVERLAPPED) NULL); 00132 }
int rs232_write | ( | void * | buffer, | |
int | size, | |||
int * | _written_bytes | |||
) |
Definition at line 135 of file ADPCM_STREAMING/rs232.c.
00136 { 00137 return WriteFile(handle_com, buffer, size, (DWORD *) _written_bytes, (LPOVERLAPPED) NULL); 00138 }