Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #ifndef __NFC_BUS_UART_H__
00027 # define __NFC_BUS_UART_H__
00028
00029 # include <stdio.h>
00030 # include <string.h>
00031 # include <stdlib.h>
00032
00033
00034 # include <nfc/nfc-types.h>
00035
00036
00037 # ifndef _WIN32
00038 # include <termios.h>
00039 # include <sys/ioctl.h>
00040 # include <unistd.h>
00041 # include <fcntl.h>
00042 # include <sys/types.h>
00043 # include <sys/stat.h>
00044 # include <limits.h>
00045 # include <sys/time.h>
00046 # include <unistd.h>
00047 # define delay_ms( X ) usleep( X * 1000 )
00048 # else
00049 # include "contrib/windows.h"
00050 # define delay_ms( X ) Sleep( X )
00051 # endif
00052
00053
00054
00055 # if defined (_WIN32)
00056 # define DEFAULT_SERIAL_PORTS { "COM1", "COM2", "COM3", "COM4", NULL }
00057 # elif defined(__APPLE__)
00058
00059 # define DEFAULT_SERIAL_PORTS { "/dev/tty.SLAB_USBtoUART", NULL }
00060 # elif defined (__FreeBSD__) || defined (__OpenBSD__)
00061
00062 # define DEFAULT_SERIAL_PORTS { "/dev/cuau0", "/dev/cuau1", "/dev/cuau2", "/dev/cuau3", NULL }
00063 # elif defined (__linux__)
00064 # define DEFAULT_SERIAL_PORTS { "/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3", "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3", NULL }
00065 # else
00066 # error "Can't determine serial string for your system"
00067 # endif
00068
00069
00070 typedef void *serial_port;
00071 # define INVALID_SERIAL_PORT (void*)(~1)
00072 # define CLAIMED_SERIAL_PORT (void*)(~2)
00073
00074 serial_port uart_open (const char *pcPortName);
00075 void uart_close (const serial_port sp);
00076
00077 void uart_set_speed (serial_port sp, const uint32_t uiPortSpeed);
00078 uint32_t uart_get_speed (const serial_port sp);
00079
00080 int uart_receive (serial_port sp, byte_t * pbtRx, size_t * pszRx);
00081 int uart_send (serial_port sp, const byte_t * pbtTx, const size_t szTx);
00082
00083 #endif // __NFC_BUS_UART_H__