typedef struct PortState { short inputRef; // Macintosh file reference numbers. short outputRef; // Added because serial ports have both // an input and output reference. int blocking; // Enable/Disable Serial Blocking Tcl_Channel devChan; /* Pointer to the channel for this device. */ int watchMask; /* OR'ed set of flags indicating which events * are being watched. */ int validMask; /* OR'ed set of flags indicating which events * are able to be watched. */ int pending; /* 1 if message is pending on queue. */ ClientData devID; // Internal Hardware Reference Number struct PortClass *portClass; /* Procedures */ struct PortState *nextPtr; /* Pointer to next registered file. */ } PortState; typedef struct PortDesc { char *name; /* Human Readable Device Name */ char *desc; /* Human Readable Device Description */ ClientData devID; /* Port reference ID */ struct PortClass *portClass; /* Procedures */ struct PortDesc *nextPtr; } PortDesc; typedef struct PortClass { char *name; /* Human Readable Class Name */ Tcl_OpenDeviceProc *openProc; /* Function to open device */ Tcl_CloseDeviceProc *closeProc; /* Function to force closed device */ Tcl_CheckDeviceProc *readyProc; /* Function to check device for events */ } PortClass; typedef struct PortEvent { Tcl_Event header; /* Information that is standard for * all events. */ PortState *infoPtr; /* Pointer to file info structure. Note * that we still have to verify that the * file exists before dereferencing this * pointer. */ } PortEvent;
These procedures are used to open channels to hardware devices. Once open channels are manipulated using the tcl commands puts, gets, close, read, fconfigure, fileevent, etc.
Class | Desc |
---|---|
serial | RS-232 or RS-422 Serial ports |
parallel | Centronics(tm) style parallel ports |
usb | Universal Serial Bus |
adb | Apple Desktop Bus |
scsi | Small Computer Simple Interface |
ps2 | IBM PS/2 Style interface ports |
New devices classes should have their own initialization function, which inserts supported device names into the device table. This is the only function that needs to be called from outside. All other methods are listed here. For a fully working example, refer to the odieMacSerialDevice.c
A template of a new device is provided in odieGenericDevice.c
Copyright © 1999 Woods Design Services. Copyright © 1999 Sean Woods.