Library:  adsComm

Installing   PV reference   VB reference   Samples

bool adsCommOpen(byte Speed);

Opens the Serial port (COM2) and sets its speed. speed parameter must be chosen in:

  • IB_SRL_300BPS : 300 bps
  • IB_SRL_600BPS : 600 bps
  • IB_SRL_1200BPS : 1200 bps
  • IB_SRL_2400BPS : 2400 bps
  • IB_SRL_4800BPS : 4800 bps
  • IB_SRL_9600BPS : 9600 bps
  • IB_SRL_19200BPS : 19200 bps
  • IB_SRL_38400BPS : 38400 bps
  • IB_SRL_57600BPS : 57600 bps

Return value: TRUE if the function succeeds, FALSE otherwise.


bool adsCommClose();

Closes the serial port (COM2)

Return value: TRUE if the function succeeds, FALSE otherwise.


bool adsCommIsOpen();

Tests the serial port state.

Return value: TRUE port is open, FALSE otherwise.


void adsCommSetCallback(ADSCOMM_CALLBACK cb);

Sets a user defined callback function for Comm operations. You must always define a callback and register it before any read and write operation.The callback must be defined this way: bool callback (byte, word); The two parameters are completely unuseful and reserved for later versions. This function is continuously fired during read and write operations and gives you a chance to abort by returning false. If you want the operation to go on you must return true. Every loop inside the function may compromise a good transfer, an infinite loop is forbidden. You should only call PollEvent for user's option and return accordingly.

int adsCommWrite(ADSCOMM_DATA *Data);

Call this function, when the port is open, to send data through the serial port. If you call the function when the port is not open the results are unpredicable (Fixed later). Data.Data is assigned the buffer pointer which contains data to send. Data.Size is assigned the number of bytes to send.

Return values:
ADSCOMM_SUCCESS
ADSCOMM_ERROR_ABORT
ADSCOMM_ERROR_DTE
ADSCOMM_ERROR_BREAK
ADSCOMM_ERROR_PROTOCOL

int adsCommRead(ADSCOMM_DATA *Data);

Call this function, when the port is open, to receive data through the serial port. If you call the function when the port is not open the results are unpredictable (Fixed later). Data.Data is assigned the buffer to store incoming data. On input Data.Size is assigned the maximum number of bytes you can receive, on output it will reflect the number of bytes received which will never be greater than the maximum number. If more bytes are received than those you asked for, they will be discarded. This is a protection from a buffer overflow since you cannot resize arrays to adapt the size.

Return values:
ADSCOMM_SUCCESS
ADSCOMM_ERROR_ABORT
ADSCOMM_ERROR_DTE
ADSCOMM_ERROR_BREAK
ADSCOMM_ERROR_PROTOCOL

typedef	struct
{
	byte *Data;
	word Size;

} ADSCOMM_DATA;