; Machine State
; Toujours abortable par BREAK ou Timer expired (ResetLink dans ce cas la)
; ReadPacket :
; Read Header (4 bytes) in global var !
; If data et cid != CTS, ACK, RDY, SCR, CMD, EOT
; Ou cid = VAR, XDP, REQ, ou RTS
; Alloc Handle (en global) and read data
; Read CheckSum
; CalcCheckSum ?
; No => ResetLink / SendPacket(CID_ERR, 0, NULL) / Redo ReadPacket
; CID == ERR => SendPacket(LAST_CID, LAST_LEN, LAST_PTR) / Redo ReadPacket
; CID != ACK => SendPacket(CID_ACK, 0, NULL)
; If time out / Break, throw an error
; SendPacket(Cid, Len, ptr)
; If Cid != ACK
; LastCid = Cid / LastLen = Len / LastPtr = ptr
; MakeHeader(MID, CID, ByteReverse(len))
; SendData(Header, 4)
; if (ptr)
; SendData(ptr, len)
; Calculate CheckSum
; SendData(CheckSum, 2)
; OSLinkCmd() :
; TRY
; ReadPacket()
; Translate Packet
; If ACK or EOT or ERR or RDY
; Exit
; If XDP (Data but we don't what to do with them)
; FreeHandle(PACKET_DATA_HD)
; If VAR or RTS (Send Variable)
; Copy Name in temp global (?) buffer.
; Check if name already exists (Variable type bof

; Yes ? SendPacket(CID_SKIP,0,NULL) / Exit
; FreeHandle(PACKET_DATA_HD)
; SendPacket(CID_CTS, 0, NULL)
; If (ReadPacket() != ACK)
; Redo Translate packet
; ReadPacket() != XDP ?
; No => Redo translate Packet
; Add file with the current file name, and use as handle PACKET_DATA_HD
; Exit (No wait for EOT)
; If REQ (Request variable)
; If it is a variable request (Check Variable Type PACKET_DATA_HD != 19, 1A, 1B, 1D, 1F)
; Search for the name in the VAT (in PACKET_DATA_HD)
; Not found ? SendPacket(CID_SKIP,0,NULL) / Exit (It seems it isn't the way AMS does, but I think it should work)
; Create the VAR Header
; SendPacket(CID_VAR, sizeof(VarHeader), &VarHeader)
; If (ReadPacket() != ACK)
; Redo Translate packet
; ReadPacket() == CTS ?
; No => Redo translate Packet
; SendPacket(CID_XDP, *((short *) VarPtr), VarPtr)
; If (ReadPacket() != ACK)
; Redo Translate packet
; SendPacket(CID_EOT, 0, NULL)
; If it is a directory request
; Not implemented yet

; If SCR
; SendPacket(CID_XDP, 3840, LCD_MEM)
; We don't check the ACK. It doesn't matter in my opinion
; Default:
; ResetLink
; ONERR
; if (Break)
; ERD_dialog(BREAK_KEY)
; else ERD_dialog(LINK_Transmission)
; OSClearBreak
; OSResetLink
; ENDTRY
Qu'en pensez-vous ? Des remarques ?
PS: Faut connaitre le protocle Ti avant de poster.