spd_message.h


Headers Index Help      Within this page: Functions Constants Variables


Overview

Functions for assembling and unpacking messages exchanged between the serial port server, spd, and libsp.a, the C interface library or SerialPort, the Java interface class.

The functions in this module are called by spd functions as well as functions in serialport.c, the main component of libsp.a.

The message format is:

command,lth,value

where command is the request code in messages sent to spd. In responses from spd it echoes the the command code unless the request was rejected, in which case it is E. value is an array of lth bytes. There is no terminating character because value can include any byte value from 0 to 255.

SerialPort - serial connections for Java
Copyright (C) 2005 Martin C Gregorie

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Contact Martin Gregorie at martin@gregorie.org

Functions


build_message

#include "spd_message.h"

int build_message(char *buff,
                   int blth,
                   char *cmd,
                   int vlth,
                   char *val,
                   int debug);

Assemble a message from its components. The assembled message is placed in buff, whose length is given by blth. The command is a string in cmd. The value is a byte array of vlth bytes in val. It returns the length of the assembled message. The function call will be traced if debug is non-zero.

In: spd_message.c

Return to the top

unpack_message

#include "spd_message.h"

int unpack_message(char *msg,
                   int mlth,
                   char *cmd,
                   int clth,
                   char *val,
                   int vlth,
                   int debug);

Unpack a message in msg of mlth total length, extracting the command into cmd and the value into val. The length of the command and value buffers are given by clth and vlth respectively. The function call will be traced if debug is non-zero. The length of the value field is returned by unpack_message().

In: spd_message.c

Return to the top

Public constants were not declared.
Public variables were not declared.
Return to the top