[fpc-pascal]PDA and Linux communication
Jonas Maebe
jonas at zeus.rug.ac.be
Tue Nov 27 12:32:40 CET 2001
On dinsdag, november 27, 2001, at 05:10 , jordi wrote:
> I'm trying to write a program that communicates with a Casio PDA.
> I have troubles with long commands which are sent in several
> packets. For example : when receive the link packet "calling up"
> -18303030303030- (7 bytes) no problem, but when receive the
> command packet "for negotiation" in this several packets
> -0130313043383131- (8 bytes)
> -3031303030323031- (8 bytes)
> -353341- (3 bytes) how can i know that I've received the full packet
> and the communication is stopped waiting for an answer?, i want to
> receive the full packet before process it, is that possible or I have to
> control it byte by byte?
You probably have to check it byte by byte, yes. You should completely
separate the receiving and the processing of the packets, just like the
compiler separates the scanner and the reading of the pascal source
code. If the scanner needs a new character, it just calls a function
called nextchar() (or something like that) which returns the next
character. This procedure checks whether the next character is already
in the memory buffer and if not, reloads the memory buffer with the next
part of the file.
You can do something similar, but with nextchar() waiting for more input
from the network.
Jonas
More information about the fpc-pascal
mailing list