TPMC815-SW-72. LynxOS Device Driver. User Manual. The Embedded I/O Company. ARCNET Controller. Version 1.0.x. Issue 1.0 May 2004

Similar documents
TIP114-SW-72. LynxOS Device Driver. User Manual. The Embedded I/O Company. 10 Channel Absolute Encoder Interface (SSI) Version 1.0.

TPMC901-SW-95. QNX4 - Neutrino Device Driver. User Manual. The Embedded I/O Company. 6/4/2 Channel Extended CAN-Bus PMC

TPMC500-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. 32 Channel 12 Bit ADC. Version 2.0.x. Issue 2.0.

TIP570-SW-95 QNX-Neutrino Device Driver TIP570 16/8 Channel 12 Bit ADC and 8 Channel 12 Bit DAC on SBS PCI40 Carrier

TIP610-SW-95 QNX-Neutrino Device Driver TIP610 16/20 Channel Digital I/O on SBS PCI40 Carrier

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC

TPMC821-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. INTERBUS Master G4 PMC. Version 1.4. Issue 1.

TIP700-SW-42. VxWorks Device Driver. User Manual. The Embedded I/O Company. Digital Output 24V DC. Version 2.0.x. Issue June 2008.

TIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013

TIP120-SW-42. VxWorks Device Driver. Motion Controller with Incremental Encoder Interface. Version 2.1.x. User Manual. Issue 2.1.

TIP670-SW-95. QNX-Neutrino Device Driver. User Manual. The Embedded I/O Company. Digital I/O. Version 1.0.x. Issue August 2008.

TPMC550-SW-12 OS-9 for PPC Device Driver 8 (4) Channels Isolated 12-bit D/A

TDRV010-SW-95. QNX6 - Neutrino Device Driver. Isolated 2x CAN Bus. Version 1.0.x. User Manual. Issue September 2016

TPMC868-SW-42. VxWorks Device Driver. 16 Channel Serial PMC. Version 2.1.x. User Manual. Issue December 2011

TPMC860-SW-82. Linux Device Driver. 4 Channel Isolated Serial Interface RS232 Version 1.4.x. User Manual. Issue 1.4.

TDRV006-SW-42. VxWorks Device Driver. 64 Digital Inputs/Outputs (Bit I/O) Version 4.0.x. User Manual. Issue December 2017

TCP866-SW-82. Linux Device Driver. User Manual. The Embedded I/O Company. 8 Channel Serial PMC Version 1.0.x. Issue 1.

TPMC851-SW-42. VxWorks Device Driver. Multifunction I/O (16 bit ADC/DAC, TTL I/O, Counter) Version 2.0.x. User Manual. Issue 2.0.

TPMC810-SW-82. Linux Device Driver. User Manual. The Embedded I/O Company. Isolated 2x CAN Bus Version 1.2.x. Issue 1.2.

CARRIER-SW-82. Linux Device Driver. IPAC Carrier Version 2.2.x. User Manual. Issue November 2017

TDRV011-SW-82. Linux Device Driver. Extended CAN Bus Version 1.0.x. User Manual. Issue April 2018

TPMC680-SW-82. Linux Device Driver. 64 Digital Input/Output Version 1.1.x. User Manual. Issue April 2010

TPMC815 ARCNET PMC. User Manual. The Embedded I/O Company. Version 2.0. Issue 1.2 November 2002 D

CARRIER-SW-42. VxWorks Device Driver. IPAC Carrier. Version 4.2.x. User Manual. Issue July 2018

TPMC Channel Motion Control. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.3 March 2003 D

TIP866-SW-95. QNX-Neutrino Device Driver. 8 Channel Serial Interface IP. Version 2.1.x. User Manual. Issue October 2009

TDRV002-SW-82. Linux Device Driver. Multi-Channel Serial Interface Version 1.8.x. User Manual. Issue November 2017

TPMC917-SW-82. Linux Device Driver. User Manual. The Embedded I/O Company. 4 MB SRAM with Battery Backup and 4 Channel Serial Interface Version 1.0.

OPTO32A 24 Input Bit, 8 Output Bit Optical Isolator Board

Advcan QNX Driver User Manual V1.02

ICS-121. VxWORKS DEVICE DRIVER MANUAL

TIP815. ARCNET Controller. Version 1.0. User Manual. Issue September 2009

TPMC Channel Isolated Serial Interface RS422/RS485. Version 1.0. User Manual. Issue July 2009

TPMC810. Isolated 2x CAN Bus. Version 1.1. User Manual. Issue June 2009

M O T O R O L A C O M P U T E R G R O U P VME DRIVER FOR LINUX USER GUIDE

TPMC816. Two Independent Channels Extended CAN Bus PMC Module. Version 2.2. User Manual. Issue August 2014

MaRTE OS Misc utilities

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

TPMC Channel Isolated Serial Interface RS232. Version 1.0. User Manual. Issue August 2017

TIP111. Motion Controller with Absolute Encoder Interface (SSI) User Manual. The Embedded I/O Company. Version 1.1. Issue 1.4 September 2005 D

spwr_base & spwr_chan

TXMC885. Four Channel 10/100/1000 Mbit/s Ethernet Adapter. Version 1.0. User Manual. Issue October 2011

PRODUCT OVERVIEW ISSUE 4

TPMC /8 Digital Inputs (24V) 16/8 Digital Outputs (24V, 0.5A) Version 3.0. User Manual. Issue June 2014

DYNAMIC ENGINEERING 150 DuBois St. Suite C, Santa Cruz, CA Fax Est.

TPMC310. Conduction Cooled PMC Isolated 2 x CAN Bus. Version 1.1. User Manual. Issue June 2014

24DSI32 24DSI12 24-bit, 32 Channel Delta-Sigma A/D Boards

TPMC Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

libnetfilter_log Reference Manual

TPMC Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

TIP550. Optically Isolated 8/4 Channel 12-bit D/A. Version 1.2. User Manual. Issue October 2009

TPMC x ADC, 16x/0x DAC and 8x Digital I/O. Version 1.0. User Manual. Issue May 2018

TIP SERCOS IP with 2 Encoder Interfaces. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.3 September 2006 D

TCP Channel Serial Interface RS232 / RS422 cpci Module. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.

10. I/O System Library

Gaisler LEON3 RTEMS driver documentation

Routing. CS5516: Project 2 Spring 2000

TCP Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

DYNAMIC ENGINEERING 150 DuBois Suite C Santa Cruz, CA (831) Fax (831) Est.

Process Creation in UNIX

T4-Input/Output Management

TPCE260. PCI Express PMC Carrier. Version 1.0. User Manual. Issue August 2014

Section 3: File I/O, JSON, Generics. Meghan Cowan

DYNAMIC ENGINEERING. 150 DuBois, Suite C Santa Cruz, CA (831) Fax (831) Est.

TPMC Digital Inputs/Outputs (Bit I/O) Version 2.0. User Manual. Issue February 2014

MicroBlaze TFTP Server User Guide

UNIX System Calls. Sys Calls versus Library Func

Simpact STREAMS ICP2432 Programmer s Guide for Windows NT DC B

TIP120. Motion Controller with Incremental Encoder Interface. Version 1.0. User Manual. Issue August 2014

CS240: Programming in C

DYNAMIC ENGINEERING 150 DuBois, Suite C Santa Cruz, CA (831) Fax (831) Est

MultiCom. for LabVIEW for Windows. Windows 95/98/NT Edition. Copyright , Viewpoint Software Solutions, Inc. All Rights Reserved

Supporting Cloud Native with DPDK and containers KEITH INTEL CORPORATION

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

Logical disks. Bach 2.2.1

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

TPMC500. Optically Isolated 32 Channel 12 Bit ADC. Version 1.1. User Manual. Issue January 2014

CSE 333 SECTION 3. POSIX I/O Functions

PMC-BiSerial-III SDLC 8-Channel SDLC Interface

MOXA Sync Board API Programmer s Manual

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

SI / XIO (SLXOS) for SCO Open Server 5.0

ECE 650 Systems Programming & Engineering. Spring 2018

File Systems: Consistency Issues

Adding a Second Ethernet Driver to NET+OS

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

MW100 CAN Bus Module Configuration Tool (MX118-CAN-M30/S1) User s Manual

Outline. Operating Systems: Devices and I/O p. 1/18

CS240: Programming in C

VMISFT-RFM2G. Drivers for Windows NT, 2000, 2003 Server and XP Operating Systems Installation Guide Document Number # Rev.

MultiCom. for LabVIEW for Windows

POSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING SOFTWARE ENGINEERING DEPARTMENT

Linux on Sun Logical Domains

High Performance Real-Time Operating Systems

Lecture files in /home/hwang/cs375/lecture05 on csserver.

DYNAMIC ENGINEERING 150 DuBois St., Suite C Santa Cruz, CA Fax Est.

Using the Cable Monitor Tool

RSLogix500 Project Report

Transcription:

The Embedded I/O Company TPMC815-SW-72 LynxOS Device Driver ARCNET Controller Version 1.0.x User Manual Issue 1.0 May 2004 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek / Germany Phone: +49-(0)4101-4058-0 Fax: +49-(0)4101-4058-19 e-mail: info@tews.com www.tews.com TEWS TECHNOLOGIES LLC 1 E. Liberty Street, Sixth Floor Reno, Nevada 89504 / USA Phone: +1 (775) 686 6077 Fax: +1 (775) 686 6024 e-mail: usasales@tews.com www.tews.com

TPMC815-SW-72 ARCNET Controller LynxOS Device Driver This document contains information, which is proprietary to TEWS TECHNOLOGIES GmbH. Any reproduction without written permission is forbidden. TEWS TECHNOLOGIES GmbH has made any effort to ensure that this manual is accurate and complete. However TEWS TECHNOLOGIES GmbH reserves the right to change the product described 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. 2004 by TEWS TECHNOLOGIES GmbH Issue Description Date 1.0 First Issue May 5, 2004 TPMC815-SW-72 - LynxOS Device Driver Page 2 of 29

Table of Content 1 INTRODUCTION... 4 2 INSTALLATION... 5 2.1 Device Driver Installation...6 2.1.1 Static Installation...6 2.1.1.1 Build the driver object...6 2.1.1.2 Create Device Information Declaration...6 2.1.1.3 Modify the Device and Driver Configuration File...6 2.1.1.4 Rebuild the Kernel...7 2.1.2 Dynamic Installation...8 2.1.2.1 Build the driver object...8 2.1.2.2 Create Device Information Declaration...8 2.1.2.3 Uninstall dynamic loaded driver...8 2.1.3 Device Information Definition File...9 2.1.4 Configuration File: CONFIG.TBL...10 3 TPMC815 DEVICE DRIVER PROGRAMMING... 11 3.1 open()...11 3.2 close()...13 3.3 read()...14 3.4 write()...16 3.5 ioctl()...18 3.5.1 TP815_C_ONLINE...19 3.5.2 TP815_C_OFFLINE...22 3.5.3 TP815_C_DIAG...23 3.5.4 TP815_C_MAP...24 3.5.5 TP815_C_FLUSH...25 3.5.6 TP815_C_TXSTATUS...26 4 DEBUGGING AND DIAGNOSTIC... 27 5 ADDITIONAL ERROR CODES... 29 TPMC815-SW-72 - LynxOS Device Driver Page 3 of 29

1 Introduction The TPMC815-SW-72 LynxOS device driver allows the operation of a TPMC815 ARCNET controller PMC on PowerPC platforms with DRM based PCI erface. The standard file (I/O) functions (open, close, read, write, ioctl) provide the basic erface for opening and closing a file descriptor and for performing device I/O and configuration operations. The TPMC815 device driver includes the following functions:! Receiving and Sending messages! Setup ARCNET controller and getting online! Getting Offline! Flushing receive buffer! Getting diagnostic value To understand all features of this device driver, it is recommended to read the TPMC815 User Manual. TPMC815-SW-72 - LynxOS Device Driver Page 4 of 29

2 Installation The software is delivered on a PC formatted 3½" HD diskette. The directory A:\TPMC815-SW-72 contains the following files: TPMC815-SW-72.pdf TPMC815-SW-72.tar This manual in PDF format Device Driver and Example sources The TAR archive TPMC815-SW-72.tar contains the following files and directories: tpmc815.c tpmc815.h tpmc815def.h arcnet.h tpmc815_info.c tpmc815_info.h tpmc815.cfg tpmc815.import Makefile example/example.c Driver source code Definitions and data structures for driver and application Definitions and data structures for the driver Definitions of controller values Device information definition Device information definition header Driver configuration file include Linker import file Device driver make file Example application source In order to perform a driver installation first extract the TAR file to a temporary directory then copy the following files to their target directories: 1. Create a new directory in the system drivers directory path /sys/drivers.xxx, where xxx represents the BSP that supports the target hardware. For example: /sys/drivers.pp_drm/tpmc815 or /sys/drivers.cpci_x86/tpmc815 2. Copy the following files to this directory: - tpmc815.c - tpmc815def.h - tpmc815.import - Makefile 3. Copy tpmc815.h to /usr/include/ 4. Copy tpmc815_info.c to /sys/devices.xxx/ or /sys/devices if /sys/devices.xxx does not exist (xxx represents the BSP). 5. Copy tpmc815_info.h to /sys/dheaders/ 6. Copy tpmc815.cfg to /sys/cfg.xxx/, where xxx represents the BSP for the target platform For example: /sys/cfg.ppc or /sys/cfg.x86... TPMC815-SW-72 - LynxOS Device Driver Page 5 of 29

2.1 Device Driver Installation The two methods of driver installation are as follows:! Static Installation! Dynamic Installation (only native LynxOS systems) 2.1.1 Static Installation With this method, the driver object code is linked with the kernel routines and is installed during system start-up. 2.1.1.1 Build the driver object 1. Change to the directory /sys/drivers.xxx/tpmc815, where xxx represents the BSP that supports the target hardware. 2. To update the library /sys/lib/libdrivers.a enter: make install 2.1.1.2 Create Device Information Declaration 1. Change to the directory /sys/devices.xxx/ or /sys/devices if /sys/devices.xxx does not exist (xxx represents the BSP). 2. Add the following dependencies to the Makefile DEVICE_FILES_all =... tpmc815_info.x And at the end of the Makefile tpmc815_info.o:$(dheaders)/tpmc815_info.h 3. To update the library /sys/lib/libdevices.a enter: make install 2.1.1.3 Modify the Device and Driver Configuration File In order to insert the driver object code o the kernel image, an appropriate entry in file CONFIG.TBL must be created. 1. Change to the directory /sys/lynx.os/ respective /sys/bsp.xxx, where xxx represents the BSP that supports the target hardware. 2. Create an entry at the end of the file CONFIG.TBL Insert the following entry at the end of this file. Be sure that the necessary TEWS TECHNOLOGIES IPAC carrier driver is included before this entry. I:tpmc815.cfg TPMC815-SW-72 - LynxOS Device Driver Page 6 of 29

2.1.1.4 Rebuild the Kernel 1. Change to the directory /sys/lynx.os/ (/sys/bsp.xxx) 2. Enter the following command to rebuild the kernel: make install 3. Reboot the newly created operating system by the following command (not necessary for KDIs): reboot an The N flag instructs init to run mknod and create all the nodes mentioned in the new nodetab. 4. After reboot you should find the following new devices (depends on the device configuration): /dev/tp815a, /dev/tp815b, /dev/tp815c, TPMC815-SW-72 - LynxOS Device Driver Page 7 of 29

2.1.2 Dynamic Installation This method allows you to install the driver after the operating system is booted. The driver object code is attached to the end of the kernel image and the operating system dynamically adds this driver to its ernal structures. The driver can also be removed dynamically. 2.1.2.1 Build the driver object 1. Change to the directory /sys/drivers.xxx/tpmc815, where xxx represents the BSP that supports the target hardware. 2. To make the dynamic link-able driver enter : make dldd 2.1.2.2 Create Device Information Declaration 1. Change to the directory /sys/drivers.xxx/tpmc815, where xxx represents the BSP that supports the target hardware. 2. To create a device definition file for the major device (this works only on native system) make t815info 3. To install the driver enter: drinstall c tpmc815.obj If successful, drinstall returns a unique <driver-id> 4. To install the major device enter: devinstall c d <driver-id> t815info The <driver-id> is returned by the drinstall command 5. To create nodes for the devices enter: mknod /dev/tp815a c <major_no> 0... The <major_no> is returned by the devinstall command. If all steps are successful completed the TPMC815 is ready to use. 2.1.2.3 Uninstall dynamic loaded driver To uninstall the TPMC815 device enter the following commands: devinstall u c <device-id> drinstall u <driver-id> TPMC815-SW-72 - LynxOS Device Driver Page 8 of 29

2.1.3 Device Information Definition File The device information definition contains information necessary to install the TPMC815 major device. The implementation of the device information definition is done through a C structure, which is defined in the header file tpmc815_info.h. This structure contains the following parameter: PCIBusNumber PCIDeviceNumber ModuleVariant Contains the PCI bus number at which the TPMC815 is connected. Valid bus numbers are in range from 0 to 255. Contains the device number (slot) at which the TPMC815 is connected. Valid device numbers are in range from 0 to 31. Contains the module variant (-11/-21) for TPMC815 V1.0, ignored for V2.0. If both PCIBusNumber and PCIDeviceNumber are 1 then the driver will auto scan for the TPMC815 device. The first device found in the scan order will be allocated by the driver for this major device. Already allocated devices can t be allocated twice. This is important to know if there are more than one TMPC815 major devices. A device information definition is unique for every TPMC815 major device. The file tpmc815_info.c on the distribution disk contains two device information declarations, tp815a_info for the first major device and tp815b_info for the second major device. If the driver should support more than two major devices it is necessary to copy and paste an existing declaration and rename it with unique name for example tp815c_info, tp815d_info and so on. It is also necessary to modify the device and driver configuration file respectively the configuration include file tpmc815.cfg. The following device declaration information uses the auto find method to detect the TPMC815 module on PCI bus. TP901_INFO tp815a_info = { }; -1, /* Auto find the TPMC815 on any PCI bus */ -1, 11, /* module variant 11 */ TPMC815-SW-72 - LynxOS Device Driver Page 9 of 29

2.1.4 Configuration File: CONFIG.TBL The device and driver configuration file CONFIG.TBL contains entries for device drivers and its major and minor device declarations. Each time the system is rebuild, the config utility read this file and produces a new set of driver and device configuration tables and a corresponding nodetab. To install the TPMC815 driver and devices o the LynxOS system, the configuration include file tpmc815.cfg must be included in the CONFIG.TBL (see also 2.1.1.3). The file tpmc815.cfg on the distribution disk contains the driver entry (C:tpmc815:\...) and a major device entry ( D:TPMC815 1:t815a_info:: ) with one minor device entry ( N: tp815a ). If the driver should support more than one major device the following entries for major and minor devices must be enabled by removing the comment character (#). By copy and paste an existing major and minor entry and renaming the new entries, it is possible to add any number of additional TPMC815 devices. This example shows a driver entry with one major device and one minor device: # Format: # C:driver-name:open:close:read:write:select:control:install:uninstall # D:device-name:info-block-name:raw-partner-name # N:node-name:minor-dev C:tpmc815:\ :tp815open:tp815close:tp815read:tp815write:\ ::tp815ioctl:tp815install:tp815uninstall D:TPMC815 1:tp815a_info:: N:tp815a:0 The configuration above creates the following node in the /dev directory. /dev/tp815a TPMC815-SW-72 - LynxOS Device Driver Page 10 of 29

3 TPMC815 Device Driver Programming LynxOS system calls are all available directly to any C program. They are implemented as ordinary function calls to "glue" routines in the system library, which trap to the OS code. Note that many system calls use data structures, which should be obtained in a program from appropriate header files. Necessary header files are listed with the system call synopsis. 3.1 open() NAME open() - open a file SYNOPSIS #include <sys/file.h> #include <sys/types.h> #include <fcntl.h> open (char *path, oflags[, mode_t mode]) DESCRIPTION Opens a file (TPMC815 device) named in path for reading and writing. The value of oflags indicates the ended use of the file. In case of a TPMC815 devices oflags must be set to O_RDWR to open the file for both reading and writing. The mode argument is required only when a file is created. Because a TPMC815 device already exists this argument is ignored. EXAMPLE fd /* open the device named "/dev/tp815a" for I/O */ fd = open ("/dev/tp815a", O_RDWR); TPMC815-SW-72 - LynxOS Device Driver Page 11 of 29

RETURNS open returns a file descriptor number if successful, or 1 on error. SEE ALSO LynxOS System Call - open() TPMC815-SW-72 - LynxOS Device Driver Page 12 of 29

3.2 close() NAME close() close a file SYNOPSIS close( fd ) DESCRIPTION This function closes an opened device. EXAMPLE result;... /* ** close the device */ result = close(fd);... RETURNS close returns 0 (OK) if successful, or 1 on error SEE ALSO LynxOS System Call - close() TPMC815-SW-72 - LynxOS Device Driver Page 13 of 29

3.3 read() NAME read() - read from a file SYNOPSIS #include <tpmc815.h> read ( fd, char *buff, count ) DESCRIPTION This function attempts to read a message from the TPMC815 associated with the file descriptor fd o a structure (TP815_MSG) poed by buff. The argument count specifies the length of the buffer and must be set to the length of the structure TP815_MSG. The TP815_MSG structure has the following layout: typedef struct { unsigned char SID; unsigned char DID; unsigned short len; /* Message data length */ unsigned char data[tp815_max_long_msg];/* Message data */ /* up to 253 bytes data for SHORT PACKET */ /* up to 508 bytes data for LONG PACKET */ unsigned long io_flags; timeout; } TP815_MSG; SID DID len Returns the source ID. The source ID is the ID of the node, which has send the message. Returns the target ID. This ID must be the ID of the actual target. Returns the length of the message. data[] This array contains the received ARCNET message. TPMC815-SW-72 - LynxOS Device Driver Page 14 of 29

io_flags This value is an ORed value of the following flags: TP815_FLUSH Flush receive buffer and wait for the next message receive. timeout Specifies the maximum time (in ticks) to wait for a message receive. If the time expires, the driver will return with a timeout error. EXAMPLE TP815_MSG fd; result; readbuf; /* Flush buffer and read message, timeout is 100 ticks */ readbuf.io_flags = TP815_FLUSH; readbuf.timeout = 100; result = read(fd, (char*)&readbuf, sizeof(readbuf)); if (result <= 0) { // process error; } RETURNS When read succeeds, the size of the read buffer (TP815_MSG) is returned. If read fails, -1 (SYSERR) is returned. On error, errno will contain a standard read error code (see also LynxOS System Call read) or a special error code (see also below Additional Error Codes) SEE ALSO LynxOS System Call - read() TPMC815 example application TPMC815-SW-72 - LynxOS Device Driver Page 15 of 29

3.4 write() NAME write() write to a file SYNOPSIS #include <tpmc815.h> write ( fd, char *buff, count ) DESCRIPTION This function attempts to write a message with the TP8MC15 associated with the file descriptor fd from a structure (TP815_MSG) poed by buff. The argument count specifies the length of the buffer and must be set to the length of the structure TP815_MSG. The TP815_MSG structure has the following layout: typedef struct { unsigned char SID; unsigned char DID; unsigned short len; /* Message data length */ unsigned char data[tp815_max_long_msg];/* Message data */ /* - 253 bytes data for SHORT PACKET */ /* - 508 bytes data for LONG PACKET */ unsigned long io_flags; timeout; } TP815_MSG; SID DID len This parameter is unused. Specifies the target ID. The target ID selects the node the message should be sent to. Specifies the length of the message data[] This array must contain the message that should be sent. TPMC815-SW-72 - LynxOS Device Driver Page 16 of 29

io_flags timeout This value is an ORed value of the following flags: T815_NOWAIT The function will return immediately and will not wait for successful transmission. Specifies the maximum time (in ticks) to wait for a successful message send. If the time expires, the driver will return with a timeout error. EXAMPLE TP815_MSG fd; result; sndbuf; /* Send a message to node 5, timeout is 100 ticks */ sndbuf.did = 5; sndbuf.timeout = 100; sndbuf.io_flags = 0; sndbuf.len = strlen( Hello ); memcpy(sndbuf.data, Hello, sndbuf.len); result = write(fd, (char*)&sndbuf, sizeof(sndbuf)); if (result <= 0) { // process error; }... RETURNS When write succeeds, the size of the write buffer (TP815_MSG) is returned. If write fails, -1 (SYSERR) is returned. On error, errno will contain a standard read error code (see also LynxOS System Call write) or a special error code (see also below Additional Error Codes) SEE ALSO LynxOS System Call - write() TPMC815 example application TPMC815-SW-72 - LynxOS Device Driver Page 17 of 29

3.5 ioctl() NAME ioctl() I/O device control SYNOPSIS #include <ioctl.h> #include <tpmc815.h> ioctl ( fd, request, char *arg) DESCRIPTION ioctl provides a way of sending special commands to a device driver. The call sends the value of request and the poer arg to the device associated with the descriptor fd. The following ioctl codes are supported by the driver and are defined in TPMC815.h: Symbol TP815_C_ONLINE TP815_C_OFFLINE TP815_C_DIAG TP815_C_MAP TP815_C_FLUSH TP815_C_TXSTATUS Meaning Configure node and set node online remove node from net return diagnostic value build a network map flush receive buffer return state of the last write request See behind for more detailed information on each control code. RETURNS ioctl returns 0 if successful, or 1 on error. On error, errno will contain a standard read error code (see also LynxOS System Call ioctl) or a special error code (see also below Additional Error Codes) SEE ALSO LynxOS System Call - ioctl(). TPMC815-SW-72 - LynxOS Device Driver Page 18 of 29

3.5.1 TP815_C_ONLINE NAME TP815_C_ONLINE Configure node end set node online DESCRIPTION With this ioctl function the selected node will be setup and set online to the connected arcnet. A poer to the configuration structure (TP815_CONFIG) is passed by the parameter arg to the driver. The TP815_CONFIG structure has the following layout: typedef struct { unsigned long io_flags; unsigned char node_id; /* used if io_flag 'NODE_ID' is set */ unsigned char network_timeout; /* this parameter controlls the Response, */ /* idle and Recon Times of our node in [us] */ /* Value Resp Idle Reconfig */ /* 0 1130 1237 1680 */ /* 1 563 624 1680 */ /* 2 285 316 1680 */ /* 3 78 86 840 */ unsigned char speed; /* this parameter determine the network speed */ /* Value Network Speed */ /* TP815_5000KBPS 5 Mbps */ /* TP815_2500KBPS 2.5 Mbps */ /* TP815_1250KBPS 1.25 Mbps */ /* TP815_625KBPS 625 Kbps */ /* TP815_312KBPS 312.5 Kbps */ } TP815_CONFIG; io_flags This parameter is an ORed value of following flags: TP815_BROADCAST Configure the controller to accept broadcast messages from the network. TP815_LONGPACKET Configure the controller to receive both short and long packets. If not set only short packets can be received. TP815_NODE_ID Use node ID specified in TP815_CONFIG. If not set, determine the node ID by reading the hardware DIP switch. TPMC815-SW-72 - LynxOS Device Driver Page 19 of 29

node_id Specifies the node address on the network for this node. This node ID is only used if the I/O flag TP815_NODE is set. Valid values are 0 to 255. network_timeout Specifies the Response, Idle and Recon Times of the ARCNET controller. All nodes should be configured with the same timeout value for proper network operation. Valid values are shown in the following table: For TPMC815-11 / -21: Value Response Time Idle Time Reconfig Time 0 596.8 µs 656 µs 840 ms 1 298.4 µs 328 µs 840 ms 2 74.7 µs 82 µs 840 ms 3 37.35 µs 41 µs 420 ms speed Determines the network speed by setting the clock prescaler to one of five possible values: Name Network Speed Moduletypes TP815_312KBPS 312.5 Kbps -11 / -21 TP815_625KBPS 625 Kbps -11 / -21 TP815_1250KBPS 1.25 Mbps -11 / -21 TP815_2500KBPS 2.5 Mbps -11 / -21 TP815_5000KBPS 5 Mbps -11 / -21 TPMC815-SW-72 - LynxOS Device Driver Page 20 of 29

EXAMPLE T815_CONF fd; result; cfgbuf; /* Set node online (node: 5, 1.25 MBit, accept long packages, */ /* Response Time: 37.35 */ cfgbuf.io_flags = TP815_NODE_ID TP815_LONGPACKET; cfgbuf.node_id = 5; cfgbuf.speed = TP815_1250KBPS; cfgbuf.network_timeout = 3; result = ioctl(fd, TP815_C_ONLINE, (char*)&cfgbuf); if (result!= OK) { // process error; } TPMC815-SW-72 - LynxOS Device Driver Page 21 of 29

3.5.2 TP815_C_OFFLINE NAME TP815_C_OFFLINE Removes the node from the net DESCRIPTION With this ioctl function the selected node will be removed from the net and set offline. No parameter needed, the parameter arg must be set to NULL EXAMPLE fd; result; result = ioctl(fd, TP815_C_OFFLINE, NULL); if (result!= OK) { // process error; } TPMC815-SW-72 - LynxOS Device Driver Page 22 of 29

3.5.3 TP815_C_DIAG NAME TP815_C_DIAG Read the number node reconfigurations DESCRIPTION This ioctl function will return the number of node reconfiguration occurred since the last read or start of initialization of the device. A poer to an unsigned value is passed by the parameter arg to the driver, where the number of reconfigurations will be returned. EXAMPLE unsigned fd; result; numrecon; result = ioctl(fd, TP815_C_DIAG, (char*)&numrecon); if (result!= OK) { // process error; } TPMC815-SW-72 - LynxOS Device Driver Page 23 of 29

3.5.4 TP815_C_MAP NAME TP815_C_MAP Build a network map DESCRIPTION With this ioctl function a network map can be build, which identifies active nodes on the net. A poer to an array of 32 byte is passed by the parameter arg to the driver. Nodes which are set online will be marked with a set bit in the array. The node assignment look like the following. The first byte of the array (index 0) returns the states of the nodes 0 to 7. Bit 0 represents node 0, node 1 can be checked with bit 1 and so on. The second byte of the array (index 1) returns the states of node 8 to 15 and so on. Example: map[0] = 0x02 map[1] = 0x03 map[2] = 0x80 map[3] = 0x00 node 1 is online, nodes 2.. 7 are offline nodes 8, 9 are online, nodes 10.. 15 are offline node 23 is online, nodes 16.. 22 are offline nodes 24.. 31 are offline...... map[31] = 0x00 nodes 248.. 255 are offline EXAMPLE unsigned char fd; result; map[32]; result = ioctl(fd, TP815_C_MAP, (char*)&map[0]); if (result!= OK) { // process error; } TPMC815-SW-72 - LynxOS Device Driver Page 24 of 29

3.5.5 TP815_C_FLUSH NAME TP815_C_FLUSH Flush the receive buffer DESCRIPTION With this ioctl function the selected node will flush its receive buffer. No parameter needed, the parameter arg must be set to NULL EXAMPLE fd; result; result = ioctl(fd, TP815_C_FLUSH, NULL); if (result!= OK) { // process error; } TPMC815-SW-72 - LynxOS Device Driver Page 25 of 29

3.5.6 TP815_C_TXSTATUS NAME TP815_C_TXSTATUS Returns the state of the last write command DESCRIPTION With this ioctl function returns the state of the last write command. This command is useful for messages that are written with the TP815_NOWAIT option. A poer to an unsigned value is passed by the parameter arg to the driver, where the status of the last write operation will be returned. Possible values for txstatus are: OK EBUSY ENOTACKN ETIMEDOUT transfer ok transfer in progress no acknowledge signal received timeout during transfer EXAMPLE unsigned fd; result; txstatus; result = ioctl(fd, TP815_C_TXSTATUS, (char*)&txstatus); if (result!= OK) { // process error; } TPMC815-SW-72 - LynxOS Device Driver Page 26 of 29

4 Debugging and Diagnostic This driver was successfully tested on a Motorola MVME2300 board and on an Intel x86 native system. It was developed on a Windows Cross Environment for LynxOS V4.0.0. If the driver will not work properly please enable debug outputs by defining the symbols DEBUG, DEBUG_TPMC, DEBUG_PCI and DEBUG_INT. The debug output should appear on the console. If not please check the symbol KKPF_PORT in uparam.h. This symbol should be configured to a valid COM port (e.g. SKDB_COM1). The debug output displays the device information data for the current major device, and a memory dump of the PCI base address registers like this. Bus = 0 Dev = 16 Func = 0 [00] = 032F1498 [04] = 02800000 [08] = 02800000 [0C] = 00000008 [10] = 02042000 [14] = 0000C001 [18] = 0000D001 [1C] = 02043000 [20] = 00000000 [24] = 00000000 [28] = 00000000 [2C] = 000B1498 [30] = 00000000 [34] = 00000040 [38] = 00000000 [3C] = 00000109 PCI Base Address 0 (PCI_RESID_BAR0) B8142000 : F1 FF FF 0F 00 FF FF 0F 00 00 00 00 00 00 00 00 B8142010 : 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 B8142020 : 00 00 00 00 00 00 00 00 E0 E0 01 54 E0 E0 01 54 B8142030 : 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 B8142040 : 0C 00 00 00 00 00 00 00 00 00 00 00 41 00 30 00 B8142050 : 00 00 78 18 6D 9B 24 02 00 00 00 00 00 00 00 00 B8142060 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B8142070 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 PCI Base Address 1 (PCI_RESID_BAR1) B0108000 : F1 FF FF 0F 00 FF FF 0F 00 00 00 00 00 00 00 00 B0108010 : 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 B0108020 : 00 00 00 00 00 00 00 00 E0 E0 01 54 E0 E0 01 54 B0108030 : 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 B0108040 : 0C 00 00 00 00 00 00 00 00 00 00 00 41 00 30 00 B0108050 : 00 00 78 18 6D 9B 24 02 00 00 00 00 00 00 00 00 B0108060 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B0108070 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 TPMC815-SW-72 - LynxOS Device Driver Page 27 of 29

PCI Base Address 2 (PCI_RESID_BAR2) B0109000 : 03 00 45 00 80 00 18 00 01 01 01 01 01 01 01 01 B0109010 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B0109020 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B0109030 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B0109040 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B0109050 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B0109060 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B0109070 : FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF PCI Base Address 3 (PCI_RESID_BAR3) B8143000 : F1 00 45 01 05 00 18 00 01 01 01 01 01 01 01 01 B8143010 : F1 00 45 02 00 00 18 00 01 01 01 01 01 01 01 01 B8143020 : F1 00 45 03 BA 00 18 00 01 01 01 01 01 01 01 01 B8143030 : F1 00 45 04 50 00 18 00 01 01 01 01 01 01 01 01 B8143040 : F1 00 45 05 2A 00 18 00 01 01 01 01 01 01 01 01 B8143050 : F1 00 45 06 6D 00 18 00 01 01 01 01 01 01 01 01 B8143060 : F1 00 45 07 A1 00 18 00 01 01 01 01 01 01 01 01 B8143070 : F1 00 45 08 6D 00 18 00 01 01 01 01 01 01 01 01 Found a TPMC815-11 V2.0 (HW-NodeID=0x01) BusNo=0 DevNo=16 RegSpace=0xB0109000 MemSpace=0xB8143000 The debug output above is only an example. Debug output on other systems may be different for addresses and data in some locations. TPMC815-SW-72 - LynxOS Device Driver Page 28 of 29

5 Additional Error Codes Error Value Description ENOTREADY 801 node is not online ENOTACKN 802 No ACK from receiver after transmission EBADPACKETSIZE 803 illegal packet size EBADSPEED 804 invalid bit-rate selected EQFULL 805 The Queue for incoming messages is full EDUPID 806 illegal (duplicate) node id TPMC815-SW-72 - LynxOS Device Driver Page 29 of 29