The Comm-Functions are heavily used in the CommunicationsProtocol.
0x028D: int Comm_Open( unsigned short parameters );
If parameters ANDed with 0xF0 is 0x20, the USB
communication channel will be opened,
else syscall 0x02AB (Serial_Open) is called
with parameters.
0x028F: int
Comm_WaitForAnyBuffer( int timeout_ms, int P2, int*P3 );
timeout has to be at least 25 ms.
P2 : if 1 the wait for receive else wait for transmit
P3 :
returns 5 : comm not open
returns 6 : timeout
returns 8 : physically disconnected
returns 0x0A : manual break
0x0290: int Comm_ReadOneByte( unsigned char*result );
Fetches one byte from the actual opened communication
pipe into result.
The function waits for 1000 ms max.
returns
0 if successful
5 if the channel is not open.
6 a timeout occurred
Waits for bytes_to_read bytes and reads them as
the case may be.
returns
0 if successful
5 if the channel is not open.
6 a timeout occurred
0x0A terminated
Spies the bytes available in the receive-buffer to be a
valid packet-type, which are 1, 2, 3, 5, 6, 0x15, 0x16 and 0x18. The code is
mapped to 0x15, 0x16, 0x2C, 0x2D, 0x13, 0x14, 0x2E or 0x0B and stored into
result.
returns
0 if successful
5 if the channel is not open.
0x18 buffer is empty
returns the currently selected communicaton channel (0=serial,
1=USB)
Does the 0x5C-padding of bytes <= 0x20 and == 0x5C in
source. Stores the result to target. The count of the
resulting target-bytes is returned in target_count. The size of
target has to be twice the size of bytes to process according to
source_count.
returns target, which is useless.
Does the reverse 0x5C-padding of bytes <= 0x20 and ==
0x5C in source. Stores the result to target. The count of
the resulting target-bytes is returned in target_count. The size of
target has to equal the size of bytes to process according to
source_count.
returns target, which is useless.
The next byte available in the current open
communications channel is returned in result.
This function spies, it does not remove any byte.
returns
0 if successful,
5 if the communications channel is not open.
8 if the physical connection could nor be established.
9 unknown error
0x18 no byte available
Tries to retrieve the next data packet. The result is
stored in rpd and as the case may be in rpd.databuffer.
Type is stored in TReceivePacketDesc.type
Subtype is stored in TReceivePacketDesc.subtype
If the packet contains data the field, TReceivePacketDesc.datasize is set
accordingly.
TReceivePacketDesc.databuffer has to point to a memory range of sufficient
size to receive the 5C-padded data.
The checksum is stored in TReceivePacketDesc.checksum.
returns
0 if successful
0x5 if the channel is not open
0x6 if a timeout occurred
0x17 if a checksum error occurred
Prepares the fields of rpd as Ack packet.
type = 0x06
subtype = subtype
datasize = datasize
datapointer = datapointer
checksum = 0
returns 0 if sucessful
returns 0x17 if datasize > 0x808.
Prepares the fields of rpd as Error packet.
type = 0x15
subtype = subtype
datasize = 0
checksum = 0
Prepares the fields of rpd as Terminate packet.
type = 0x18
subtype = subtype
datasize = 0
checksum = 0
Prepares the fields of rpd as Roleswap packet.
type = 0x03
subtype = subtype
datasize = 0
checksum = 0
Prepares the fields of rpd as Check packet.
type = 0x05
subtype = subtype
datasize = 0
checksum = 0
Prepares the fields of rpd as Command packet.
type = 0x01
subtype = subtype
datasize = datasize
datapointer = datapointer
checksum = 0
returns 0 if sucessful
returns 0x17 if datasize > 0x808.
Prepares the fields of rpd as Data packet.
type = 0x02
subtype = subtype
datasize = datasize
datapointer = datapointer
checksum = 0
returns 0 if sucessful
returns 0x09 if datapointer is null.
returns 0x17 if datasize > 0x808.
This syscall is used as handler for timer 4, hence never called directly.
(02.06.2012 15:39:06)