background image

TPMC866-SW-42 - VxWorks Device Driver

Page 18 of 37

EXAMPLE

#define

BUFSIZE

100

int

fd;

char

buffer[BUFSIZE];

int

retval;

/*------------------------------

Read data from specified device

------------------------------*/

retval = read(fd, buffer, BUFSIZE);

if (retval != ERROR)

{

printf(“%d bytes read\n”, retval);

}

else

{

/* handle the read error */

}

RETURNS

Number of bytes read or ERROR. If the function fails an error code will be stored in

errno

.

SEE ALSO

ioLib, basic I/O routine - read()

Summary of Contents for TPMC866-SW-42

Page 1: ...0 1 September 2008 TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC Am Bahnhof 7 25469 Halstenbek Germany www tews com Phone 49 0 4101 4058 0 Fax 49 0 4101 4058 19 e mail info tews com 9190 Double Diamon...

Page 2: ...ibed in this document at any time without notice TEWS TECHNOLOGIES GmbH is not liable for any damage arising out of the application or use of the device described herein 1998 2008 by TEWS TECHNOLOGIES...

Page 3: ...3 1 tpmc866Drv 7 3 2 tpmc866DevCreate 9 4 I O INTERFACE FUNCTIONS 13 4 1 open 13 4 2 close 15 4 3 read 17 4 4 write 19 4 5 ioctl 21 4 5 1 FIOBAUDRATE 23 4 5 2 FIOFIFO 24 4 5 3 FIODATABITS 26 4 5 4 FIO...

Page 4: ...oing of input characters optional stripping of the parity bit from 8 bit input optional special characters for shell abort and system restart Additionally the following functions are supported select...

Page 5: ...led description of the project facility please refer to your Tornado User s Guide 2 2 Special installation for Intel x86 based targets The TPMC866 device driver is fully adapted for Intel x86 based ta...

Page 6: ...urce requirement The table gives an overview over the system resources that will be needed by the driver Resource Driver requirement Devices requirement Memory 1 KB 1KB Stack 2 KB Semaphores 1 Memory...

Page 7: ...PMC866 driver in the I O system SYNOPSIS include tpmc866 h STATUS tpmc866Drv void DESCRIPTION This function searches for devices on the PCI bus allocates driver and device resources initializes them a...

Page 8: ...OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error codes are stored in errno and can be read with the function errnoGet Error code Description ENXIO No TPMC...

Page 9: ...tes a device on a specified serial channel that will be serviced by the TPMC866 driver This function must be called before performing any I O request to this device PARAMETER name This string specifie...

Page 10: ...ceiver FIFO trigger level TPMC866 10 11 use the predefined values in tpmc866 h TPMC866 12 allowed values are 0 127 and TP866F_NO If one of the FIFO trigger levels is set to TP866F_NO the other level i...

Page 11: ...C866_12 Module is treated as TPMC866 12 EXAMPLE include tpmc866 h STATUS result TP866_CHANCONF tp866setup 115200 115200 Baud OPT_TERMINAL Terminal options TP866F_NO TP866F_NO no FIFO TP866DB_8 TP866SB...

Page 12: ...TPMC866 SW 42 VxWorks Device Driver Page 12 of 37 RETURNS OK or ERROR if the driver is not installed or the channel is invalid or the device already exists...

Page 13: ...O system 4 1 open NAME open opens a device or file SYNOPSIS int open const char name int flags int mode DESCRIPTION Before I O can be performed to the TPMC866 device a file descriptor must be opened...

Page 14: ...EXAMPLE int fd Open the device named tp866 1 for I O fd open tp866 1 0 0 if fd ERROR Handle errror RETURNS A device descriptor number or ERROR if the device does not exist or no device descriptors ar...

Page 15: ...fd DESCRIPTION This function closes opened devices PARAMETER fd This file descriptor specifies the device to be closed The file descriptor has been returned by the open function EXAMPLE int fd STATUS...

Page 16: ...evice Driver Page 16 of 37 ERROR CODES The error code can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual SEE ALSO ioLib b...

Page 17: ...ON This function can be used to read data from the device PARAMETER fd This file descriptor specifies the device to be used The file descriptor has been returned by the open function buffer This argum...

Page 18: ...fer BUFSIZE int retval Read data from specified device retval read fd buffer BUFSIZE if retval ERROR printf d bytes read n retval else handle the read error RETURNS Number of bytes read or ERROR If th...

Page 19: ...es DESCRIPTION This function can be used to write data to the device PARAMETER fd This file descriptor specifies the device to be used The file descriptor has been returned by the open function buffer...

Page 20: ...retval Write data to a specified device retval write fd buffer strlen buffer if retval ERROR printf d bytes written n retval else handle the write error RETURNS Number of bytes written or ERROR If the...

Page 21: ...he function that shall be executed In addition to the VxWorks standard ioctl funtions for serial devices tyLib the following functions are defined Function Description FIOBAUDRATE configure channel ba...

Page 22: ...th the function RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error code can be read with the function errnoGet The error code is a standard error cod...

Page 23: ...ud rate is always set to the next selectable value The selectable baud rates are calculated as follows Baudrate 460800 Baud n n must be selected between 1 and 65536 Examples Required Baud Rate Selecte...

Page 24: ...bytes are unused RR the third byte selects the receive trigger TP866F_NO TP866F_R8 TP866F_R16 TP866F_R56 TP866F_R60 TT the least significant bit selects the transmitter trigger level TP866F_NO TP866F...

Page 25: ...tpmc866 h int fd int result Set FIFO triggering to 8 bytes for receive and 16 bytes for transmit result ioctl fd FIOFIFO TP866F_R8 8 TP866F_T16 if result OK Success else Function failed ERROR CODES E...

Page 26: ...d value to the device driver The following values are possible value description TP866DB_5 use 5 data bits TP866DB_6 use 6 data bits TP866DB_7 use 7 data bits TP866DB_8 use 8 data bits EXAMPLE include...

Page 27: ...lected value to the device driver The following values are possible value description TP866SB_10 use 1 stop bit TP866SB_15 use 1 5 stop bits TP866SB_20 use 2 stop bits EXAMPLE include tpmc866 h int fd...

Page 28: ...e selected value to the device driver The following values are possible value description TP866EVP use EVEN parity TP866ODP use ODD parity TP866NOP do not use parity EXAMPLE include tpmc866 h int fd i...

Page 29: ...d The hardware handshake signals are only generated for the controller s internal FIFOs the writing to the VxWorks FIFOs will not be stopped if they are full So there will be data lost if the applicat...

Page 30: ...ing for the specific channel The function specific control parameter arg is not used This function is only available for TPMC866 10 used for other types will lead to an error EXAMPLE include tpmc866 h...

Page 31: ...he break bit of the controller for the specific channel This will produce a break signal on the transmit line The function specific control parameter arg is not used EXAMPLE include tpmc866 h int fd i...

Page 32: ...control function removes the break flag of the controller for the specific channel The function specific control parameter arg is not used EXAMPLE include tpmc866 h int fd int result Clear the break...

Page 33: ...eter arg passes as pointer to a char value to the device driver where the result will be returned A result of TRUE means that a break has been received A result of FALSE says that no break has been re...

Page 34: ...meter arg passes an pointer to a char value to the device driver where the result will be returned Following results are possible Bit Value Error 0 1 0 framing error 1 1 1 parity error EXAMPLE include...

Page 35: ...iver s internal settings will be set to the default configuration and the channel will be set up with its default settings The function specific control parameter arg is not used EXAMPLE include tpmc8...

Page 36: ...tes are in FIFO TP866F_R16 1 FIFO trigger if 16 received bytes are in FIFO TP866F_R56 2 FIFO trigger if 56 received bytes are in FIFO TP866F_R60 3 FIFO trigger if 60 received bytes are in FIFO DATABIT...

Page 37: ...ver Page 37 of 37 5 2 Additional Error Codes If the device driver creates an error the error codes are stored in the errno They can be read with the VxWorks function errnoGet or printErrno S_tp866Drv_...

Reviews: