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