01.06.2013 Views

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Interrupt 0xAC service 0x20: API_REGISTERCALLBACK_PASCAL, Pascal user callback<br />

Parameters<br />

AH<br />

BX<br />

CX<br />

ES:DI<br />

Registers a user callback function written in Pascal for events occurring on a TCP socket.<br />

0x20 (= API_REGISTERCALLBACK_PASCAL)<br />

Socket descriptor<br />

Event flag mask (see below)<br />

Pointer to callback function (see below)<br />

Return Value<br />

Comments<br />

DX = 0 success<br />

DX != 0 AX: contains error code<br />

The number of Pascal TCP callback functions is limited to 10.<br />

The first action required in your callback function is to read the pointer to the PacCallBack record passed in<br />

registers ES:DI. This can be accomplished by implementing the callback function as follows (Borland Pascal):<br />

procedure socketCallBackFunc; interrupt;<br />

var<br />

ESReg : Integer;<br />

DIReg : Integer;<br />

CBParamPtr : CallBackParamPtr;<br />

begin<br />

(*********************************)<br />

(* Required to get the Parameter *)<br />

asm<br />

mov ax, es<br />

mov ESReg, ax<br />

mov ax, di<br />

mov DIReg, ax<br />

end;<br />

(*********************************)<br />

end;<br />

[... your code ...]<br />

Before closing a socket, you should remove the callback function. This is done by calling this API function with<br />

a null pointer in ES:DI and value 0 in register CX.<br />

The event flags are defined as follows:<br />

const<br />

CB_CONNECT_COMPLT = $0001;<br />

CB_ACCEPT = $0002;<br />

CB_RECV = $0004;<br />

CB_SEND_COMPLT = $0010;<br />

CB_REMOTE_CLOSE = $0020;<br />

Page 122 / 400

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!