amunits: fixed pack and checked against SDK serial unit

git-svn-id: trunk@40496 -
This commit is contained in:
marcus 2018-12-07 18:56:19 +00:00
parent 1e15e35eab
commit 5881516cf4

View File

@ -16,25 +16,23 @@
unit serial; unit serial;
INTERFACE interface
{$PACKRECORDS 2}
uses exec; uses
exec;
type
Type // array of termination char's to use,see serial.doc setparams
PIOTArray = ^TIOTArray;
TIOTArray = record
TermArray0: LongWord;
TermArray1: LongWord;
end;
{ array of termination char's } const
{ to use,see serial.doc setparams } SER_DEFAULT_CTLCHAR = $11130000; // default chars for xON,xOFF
pIOTArray = ^tIOTArray;
tIOTArray = record
TermArray0 : ULONG;
TermArray1 : ULONG;
end;
Const
SER_DEFAULT_CTLCHAR = $11130000; { default chars for xON,xOFF }
{ You may change these via SETPARAMS. At this time, parity is not { You may change these via SETPARAMS. At this time, parity is not
calculated for xON/xOFF characters. You must supply them with the calculated for xON/xOFF characters. You must supply them with the
@ -45,151 +43,123 @@ Const
IOExtSer-sized structure or you may overlay innocent memory !! } IOExtSer-sized structure or you may overlay innocent memory !! }
{****************************************************************} {****************************************************************}
Type type
TIOExtSer = record
IOSer: TIOStdReq;
io_CtlChar: LongWord; // control characters
io_RBufLen: LongWord; // length in bytes of serial read buffer
io_ExtFlags: LongWord; // additional serial flags (SEXTB_*)
io_Baud: LongWord; // baud rate
io_BrkTime: LongWord; // duration of break in microseconds
io_TermArray: TIOTArray; // termination character array
io_ReadLen: Byte; // number of bits per read character
io_WriteLen: Byte; // number of bits per write character
io_StopBits: Byte; // number of stopbits for read
io_SerFlags: Byte; // serial device flags (SERB_*)
io_Status: Word; // status of serial port and lines (IO_STATF_*, IOSTF_*)
end;
PIOExtSer = ^TIOExtSer;
pIOExtSer = ^tIOExtSer; { status of serial port, as follows:
tIOExtSer = record BIT ACTIVE FUNCTION
IOSer : tIOStdReq; 0 --- reserved
1 --- reserved
2 high Connected to parallel "select" on the A1000.
Connected to both the parallel "select" and
serial "ring indicator" pins on the A500 &
A2000. Take care when making cables.
3 low Data Set Ready
4 low Clear To Send
5 low Carrier Detect
6 low Ready To Send
7 low Data Terminal Ready
8 high read overrun
9 high break sent
10 high break received
11 high transmit x-OFFed
12 high receive x-OFFed
13-15 reserved}
{ STRUCT MsgNode const
* 0 APTR Succ SDCMD_QUERY = CMD_NONSTD;
* 4 APTR Pred SDCMD_BREAK = CMD_NONSTD + 1;
* 8 UBYTE Type SDCMD_SETPARAMS = CMD_NONSTD + 2;
* 9 UBYTE Pri
* A APTR Name
* E APTR ReplyPort
* 12 UWORD MNLength
* STRUCT IOExt
* 14 APTR io_Device
* 18 APTR io_Unit
* 1C UWORD io_Command
* 1E UBYTE io_Flags
* 1F UBYTE io_Error
* STRUCT IOStdExt
* 20 ULONG io_Actual
* 24 ULONG io_Length
* 28 APTR io_Data
* 2C ULONG io_Offset
*
* 30 }
io_CtlChar : ULONG; { control char's (order = xON,xOFF,INQ,ACK) } // flags of TIOExtSer.io_SerFlags
io_RBufLen : ULONG; { length in bytes of serial port's read buffer } SERB_XDISABLED = 7; // xOn-xOff feature disabled
io_ExtFlags : ULONG; { additional serial flags (see bitdefs below) } SERF_XDISABLED = 1 shl SERB_XDISABLED;
io_Baud : ULONG; { baud rate requested (true baud) } SERB_EOFMODE = 6; // EOF mode enabled
io_BrkTime : ULONG; { duration of break signal in MICROseconds } SERF_EOFMODE = 1 shl SERB_EOFMODE;
io_TermArray : tIOTArray; { termination character array } SERB_SHARED = 5; // non-exclusive access
io_ReadLen : Byte; { bits per read character (# of bits) } SERF_SHARED = 1 shl SERB_SHARED;
io_WriteLen : Byte; { bits per write character (# of bits) } SERB_RAD_BOOGIE = 4; // high-speed mode active
io_StopBits : Byte; { stopbits for read (# of bits) } SERF_RAD_BOOGIE = 1 shl SERB_RAD_BOOGIE;
io_SerFlags : Byte; { see SerFlags bit definitions below } SERB_QUEUEDBRK = 3; // queue this Break ioRqst
io_Status : Word; SERF_QUEUEDBRK = 1 shl SERB_QUEUEDBRK;
end; SERB_7WIRE = 2; // RS232 7-wire protocol
SERF_7WIRE = 1 shl SERB_7WIRE;
SERB_PARTY_ODD = 1; // parity feature enabled
SERF_PARTY_ODD = 1 shl SERB_PARTY_ODD;
SERB_PARTY_ON = 0; // parity-enabled
SERF_PARTY_ON = 1 shl SERB_PARTY_ON;
{ status of serial port, as follows: // These now refect the actual bit positions in the TIOExtSer.io_Status LongWord
* BIT ACTIVE FUNCTION IO_STATB_XOFFREAD = 12; // receive currently xOFF'ed
* 0 --- reserved IO_STATF_XOFFREAD = 1 shl IO_STATB_XOFFREAD;
* 1 --- reserved IO_STATB_XOFFWRITE = 11; // transmit currently xOFF'ed
* 2 high Connected to parallel "select" on the A1000. IO_STATF_XOFFWRITE = 1 shl IO_STATB_XOFFWRITE;
* Connected to both the parallel "select" and IO_STATB_READBREAK = 10; // break was latest input
* serial "ring indicator" pins on the A500 & IO_STATF_READBREAK = 1 shl IO_STATB_READBREAK;
* A2000. Take care when making cables. IO_STATB_WROTEBREAK = 9; // break was latest output
* 3 low Data Set Ready IO_STATF_WROTEBREAK = 1 shl IO_STATB_WROTEBREAK;
* 4 low Clear To Send IO_STATB_OVERRUN = 8; // status word RBF overrun
* 5 low Carrier Detect IO_STATF_OVERRUN = 1 shl IO_STATB_OVERRUN;
* 6 low Ready To Send
* 7 low Data Terminal Ready
* 8 high read overrun
* 9 high break sent
* 10 high break received
* 11 high transmit x-OFFed
* 12 high receive x-OFFed
* 13-15 reserved
}
Const // TIOExtSer.io_ExtFlags
SEXTB_MSPON = 1; // Use mark-space parity, instead of odd-even.
SEXTF_MSPON = 1 shl SEXTB_MSPON;
SEXTB_MARK = 0; // if mark-space, use mark
SEXTF_MARK = 1 shl SEXTB_MARK;
SDCMD_QUERY = CMD_NONSTD; SerErr_DevBusy = 1;
SDCMD_BREAK = CMD_NONSTD + 1; SerErr_BaudMismatch = 2; // baud rate not supported by hardware
SDCMD_SETPARAMS = CMD_NONSTD + 2; SerErr_BufErr = 4; // Failed to allocate new read buffer
SerErr_InvParam = 5;
SerErr_LineErr = 6;
SERB_XDISABLED = 7; { io_SerFlags xOn-xOff feature disabled bit } SerErr_ParityErr = 9;
SERF_XDISABLED = 128; { " xOn-xOff feature disabled mask } SerErr_TimerErr = 11; // (See the serial/OpenDevice autodoc)
SERB_EOFMODE = 6; { " EOF mode enabled bit } SerErr_BufOverflow = 12;
SERF_EOFMODE = 64; { " EOF mode enabled mask } SerErr_NoDSR = 13;
SERB_SHARED = 5; { " non-exclusive access bit } SerErr_DetectedBreak = 15;
SERF_SHARED = 32; { " non-exclusive access mask }
SERB_RAD_BOOGIE = 4; { " high-speed mode active bit }
SERF_RAD_BOOGIE = 16; { " high-speed mode active mask }
SERB_QUEUEDBRK = 3; { " queue this Break ioRqst }
SERF_QUEUEDBRK = 8; { " queue this Break ioRqst }
SERB_7WIRE = 2; { " RS232 7-wire protocol }
SERF_7WIRE = 4; { " RS232 7-wire protocol }
SERB_PARTY_ODD = 1; { " parity feature enabled bit }
SERF_PARTY_ODD = 2; { " parity feature enabled mask }
SERB_PARTY_ON = 0; { " parity-enabled bit }
SERF_PARTY_ON = 1; { " parity-enabled mask }
{ These now refect the actual bit positions in the io_Status UWORD }
IO_STATB_XOFFREAD = 12; { io_Status receive currently xOFF'ed bit }
IO_STATF_XOFFREAD = $1000; { " receive currently xOFF'ed mask }
IO_STATB_XOFFWRITE = 11; { " transmit currently xOFF'ed bit }
IO_STATF_XOFFWRITE = $0800; { " transmit currently xOFF'ed mask }
IO_STATB_READBREAK = 10; { " break was latest input bit }
IO_STATF_READBREAK = $0400; { " break was latest input mask }
IO_STATB_WROTEBREAK = 9; { " break was latest output bit }
IO_STATF_WROTEBREAK = $0200; { " break was latest output mask }
IO_STATB_OVERRUN = 8; { " status word RBF overrun bit }
IO_STATF_OVERRUN = $0100; { " status word RBF overrun mask }
SEXTB_MSPON = 1; { io_ExtFlags. Use mark-space parity, }
{ instead of odd-even. }
SEXTF_MSPON = 2; { " mark-space parity mask }
SEXTB_MARK = 0; { " if mark-space, use mark }
SEXTF_MARK = 1; { " if mark-space, use mark mask }
SerErr_DevBusy = 1;
SerErr_BaudMismatch = 2; { baud rate not supported by hardware }
SerErr_BufErr = 4; { Failed to allocate new read buffer }
SerErr_InvParam = 5;
SerErr_LineErr = 6;
SerErr_ParityErr = 9;
SerErr_TimerErr = 11; {(See the serial/OpenDevice autodoc)}
SerErr_BufOverflow = 12;
SerErr_NoDSR = 13;
SerErr_DetectedBreak = 15;
{ These defines refer to the HIGH ORDER byte of io_Status. They have { These defines refer to the HIGH ORDER byte of io_Status. They have
been replaced by the new, corrected ones above } been replaced by the new, corrected ones above }
IOSTB_XOFFREAD = 4; { iost_hob receive currently xOFF'ed bit } IOSTB_XOFFREAD = 4; // receive currently xOFF'ed
IOSTF_XOFFREAD = 16; { " receive currently xOFF'ed mask } IOSTF_XOFFREAD = 1 shl IOSTB_XOFFREAD;
IOSTB_XOFFWRITE = 3; { " transmit currently xOFF'ed bit } IOSTB_XOFFWRITE = 3; // transmit currently xOFF'ed
IOSTF_XOFFWRITE = 8; { " transmit currently xOFF'ed mask } IOSTF_XOFFWRITE = 1 shl IOSTB_XOFFWRITE;
IOSTB_READBREAK = 2; { " break was latest input bit } IOSTB_READBREAK = 2; // break was latest input
IOSTF_READBREAK = 4; { " break was latest input mask } IOSTF_READBREAK = 1 shl IOSTB_READBREAK;
IOSTB_WROTEBREAK= 1; { " break was latest output bit } IOSTB_WROTEBREAK= 1; // break was latest output
IOSTF_WROTEBREAK= 2; { " break was latest output mask } IOSTF_WROTEBREAK= 1 shl IOSTB_WROTEBREAK;
IOSTB_OVERRUN = 0; { " status word RBF overrun bit } IOSTB_OVERRUN = 0; // status word RBF overrun
IOSTF_OVERRUN = 1; { " status word RBF overrun mask } IOSTF_OVERRUN = 1 shl IOSTB_OVERRUN;
IOSERB_BUFRREAD = 7 ; { io_Flags from read buffer bit } // TIOExtSer.io_Flags
IOSERF_BUFRREAD = 128; { " from read buffer mask } IOSERB_BUFRREAD = 7; // from read buffer
IOSERB_QUEUED = 6 ; { " rqst-queued bit } IOSERF_BUFRREAD = 1 shl IOSERB_BUFRREAD;
IOSERF_QUEUED = 64 ; { " rqst-queued mask } IOSERB_QUEUED = 6; // rqst-queued
IOSERB_ABORT = 5 ; { " rqst-aborted bit } IOSERF_QUEUED = 1 shl IOSERB_QUEUED;
IOSERF_ABORT = 32 ; { " rqst-aborted mask } IOSERB_ABORT = 5; // rqst-aborted
IOSERB_ACTIVE = 4 ; { " rqst-qued-OR-current bit } IOSERF_ABORT = 1 shl IOSERB_ABORT;
IOSERF_ACTIVE = 16 ; { " rqst-qued-OR-current mask } IOSERB_ACTIVE = 4; // rqst-qued-OR-current
IOSERF_ACTIVE = 1 shl IOSERB_ACTIVE;
SERIALNAME: PChar = 'serial.device';
implementation
SERIALNAME : PChar = 'serial.device';
IMPLEMENTATION
end. end.