home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
HAM
/
BPQ407A.ZIP
/
SAMPS.ZIP
/
BPQ_TO_C.DOC
next >
Wrap
Text File
|
1992-06-20
|
7KB
|
324 lines
A set of 'C' callable routines for Version 4 of the G8BPQ switch.
By Steve Coleman, G4YFB.
This set of calls are contained in the object file BPQ.OBJ.
These have been written in assembler, to be called from C. They
enable easy implementation of the new BPQ interface to be used by
C programs. The object has been assembled in the Large model, so
all are defined as FAR PROCedures. You will need to use the FAR
over-ride in your C program for small memory models, as the
return from the module routines is retf.
The include file BPQ.H should be added to your source file.
PLEASE NOTE!!
=============
Any help you may need with these routines should be sent to ME, NOT
to John, G8BPQ who has enough to do without answering questions
about other peoples code!
Steve Coleman, QTHR 1991 or @ GB7RDG.
===================================
Here is a list of the procedures available, their calling
parameters and return values, if any.
Set the HOSTINTERRUPT. This routine tells the module what
INTerrupt number to use.
***********
void far set_int(int);
int BPQ_INT;
set_int(BPQ_INT);
**********
Set the application mask and flag, BPQ command #1
void far set_appl(int, int, int);
int stream;
int appl_mask;
int appl_flag;
set_appl(stream, appl_mask, appl_flag);
The two parameters are APPLication mask and APPLication flags.
**********
Send a frame to the switch, BPQ commands #2
This command sends a frame to the switch, to be transmitted.
void far send_frame(int, int, int, int);
char *buffer = "Just a test!";
int stream;
send_frame(stream, FP_OFF(buffer), FP_SEG(buffer), strlen(buffer));
**********
Receive a frame from the switch, BPQ command #3
This command will return the length of the frame, or 0 if no data
available.
int far get_frame(int, int, int);
char *buffer;
int buf_len;
int stream;
buf_len = get_frame(stream, FP_OFF(buffer), FP_SEG(buffer));
if(buf_len) {
/* data has been read into buffer */
**********
Get the current status of a stream, BPQ command #4
This functions returns the current status of a stream:
int far get_status(int);
int stream;
int stat;
stat = get_status(stream);
stat will return the following:
0 no change of state
1 stream is connected
2 stream is disconnected
Thus, if the call returns 0, no change of state has taken place
since the last time this command was called, so a non-zero return
will indicate either a connect or disconnect, depending on the
context in which the command was called.
**********
Check to see if a particular stream is connected or not. This is
used to find a free stream for your applications!! It is almost
the same as get_status, but return the connected status of a
stream.
int far con_status(int);
int stream;
int stat;
stat = con_stat(stream);
Acknowledge the change of status, BPQ command #5.
!!!THIS COMMAND MUST be called before any other stream changes
can be reported!!!
void far ack_status(int);
int stream;
int stat;
stat = get_status(stream);
if (stat) {
ack_status(stream);
/* see what the change is */
if (stat) {
/* stream has connected */
.
.
else {
/* stream has disconnected */
**********
Control the streams session type, BPQ command #6
This function defines what the type of session is.
void far set_session(int, int);
#define CON_TO_NODE 1 /* Connect to the node */
#define DISC 2 /* Disconnect from the node */
#define RET_TO_NODE 3 /* As 2, but return the user to the node */
int stream;
set_session(stream, DISC);
This will disconnect the user completely.
**********
Return the number of frames queued for receive, BPQ command #7
(Part)
This function will return the number of frames waiting to be
received, this is CONNECTED data, NOT monitored data( this is
covered later).
int far rx_queue(int);
int stream;
int rx_que_len;
rx_que_len = rx_que(stream);
##########
Return the number of un-acked frames to be transmitted, BPQ
command #7 (Part)
This function returns the number of unsent frames.
int far tx_queue(int);
int stream;
int tx_que_len;
tx_que_len = tx_queue(stream);
##########
Return the number of buffers left in the node, BPQ command #7
(Part)
Returns the number of free buffers the node has left.
int far free_buffs(int);
int stream;
int fre_bufs;
fre_bufs = free_buffs(stream);
**********
Transmit a RAW (KISS) data frame, BPQ command #10.
!!!! THIS COMMAND TRANSMITS THE FRAME ON THE RADIO PORT (not the
normal 'stream') !!!!
void far raw_tx(int, int, int, int);
int radio_port;
char *buffer;
int length;
raw_tx(radio_port, FP_OFF(buffer), FP_SEG(buffer), length);
**********
Receive a RAW(KISS) frame, BPQ command 11.
This command is used for monitoring, all calls will be in AX.25
format. To enable monitoring, set bit #7 of the application flag
in function #1 above.
int far raw_rx(int, int, int);
This will return the length of the received data, or 0 if none is
available.
int stream;
char *buffer;
int raw_len;
raw_len = raw_rx(stream, FP_OFF(buffer), FP_SEG(buffer));
if (!raw_len) {
/* No data available */
else {
/* process the raw data */
**********
Return the HOSTINTERRUPT. This is NOT part of the BPQ commands,
but has been added to make life just a bit easier!! It assumes
that the configuration file BPQCFG.BIN is in the same default
directory. This function also sets the Host interrupt, so the
function set_int is not really needed, but is included for
completeness.
int far get_host(void);
Returns the host interrupt or 0 if it fails.
int BPQ_INT;
BPQ_INT = get_host();
if(!BPQ_INT) {
printf("\nError!);
**********
This function checks to see if the switch is loaded and returns
the version number, or 0 if the switch is not loaded. This is
NOT part of the BPQ commands, just an extension here to make life
easy! The returned version number is in the form MAJOR/MINOR
versions, ie, version 4.03 will be returned as 0x403
int far check_load(void);
int loaded;
loaded = check_load();
if (!loaded) {
/* switch not loaded! */
else {
/* check the version numbers! */
.
This function should be called after get_host, as that routine
will have loaded the host interrupt, or failed. This is just a
further check that all is well!!
**********
Get the connected callsign, BPQ command #8
void far get_call(int, int, int);
This function returns the connected callsign, in ascii, which is
10 bytes, space padded.
char *buffer;
int stream;
get_call(stream, FP_OFF(buffer), FP_SEG(buffer));