home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / bbs / samps.zip / BPQ_TO_C.DOC next >
Text File  |  1992-06-20  |  7KB  |  324 lines

  1. A set of 'C' callable routines for Version 4 of the G8BPQ switch.
  2.  
  3.                     By Steve Coleman, G4YFB.
  4.  
  5. This set of calls are contained in the object file BPQ.OBJ. 
  6. These have been written in assembler, to be called from C.  They
  7. enable easy implementation of the new BPQ interface to be used by
  8. C programs.  The object has been assembled in the Large model, so
  9. all are defined as FAR PROCedures.  You will need to use the FAR
  10. over-ride in your C program for small memory models, as the
  11. return from the module routines is retf.
  12.  
  13. The include file BPQ.H should be added to your source file.
  14.  
  15.  
  16.                         PLEASE NOTE!!
  17.                         =============
  18.  
  19. Any help you may need with these routines should be sent to ME, NOT 
  20. to John, G8BPQ who has enough to do without answering questions 
  21. about other peoples code!
  22.  
  23. Steve Coleman, QTHR 1991 or @ GB7RDG.
  24.  
  25.                ===================================
  26.  
  27. Here is a list of the procedures available, their calling
  28. parameters and return values, if any.
  29.  
  30. Set the HOSTINTERRUPT.  This routine tells the module what
  31. INTerrupt number to use.
  32.  
  33.                            ***********
  34.  
  35. void far set_int(int);
  36.  
  37. int BPQ_INT;
  38.  
  39. set_int(BPQ_INT);
  40.  
  41.                            **********
  42.  
  43. Set the application mask and flag, BPQ command #1
  44.  
  45. void far set_appl(int, int, int);
  46.  
  47. int stream;
  48. int appl_mask;
  49. int appl_flag;
  50.  
  51. set_appl(stream, appl_mask, appl_flag);
  52.  
  53. The two parameters are APPLication mask and APPLication flags.
  54.  
  55.                            **********
  56.  
  57. Send a frame to the switch, BPQ commands #2
  58. This command sends a frame to the switch, to be transmitted.
  59.  
  60. void far send_frame(int, int, int, int);
  61.  
  62. char *buffer = "Just a test!";
  63. int stream;
  64.  
  65. send_frame(stream, FP_OFF(buffer), FP_SEG(buffer), strlen(buffer));
  66.  
  67.                            **********
  68.  
  69. Receive a frame from the switch, BPQ command #3
  70. This command will return the length of the frame, or 0 if no data
  71. available.
  72.  
  73. int far get_frame(int, int, int);
  74.  
  75. char *buffer;
  76. int buf_len;
  77. int stream;
  78.  
  79. buf_len = get_frame(stream, FP_OFF(buffer), FP_SEG(buffer));
  80.  
  81. if(buf_len) {
  82.  
  83. /* data has been read into buffer */
  84.  
  85.                            **********
  86.  
  87. Get the current status of a stream, BPQ command #4
  88. This functions returns the current status of a stream:
  89.  
  90. int far get_status(int);
  91.  
  92. int stream;
  93. int stat;
  94.  
  95. stat = get_status(stream);
  96.  
  97. stat will return the following:
  98.  
  99. 0 no change of state
  100.  
  101. 1 stream is connected
  102. 2 stream is disconnected
  103.  
  104. Thus, if the call returns 0, no change of state has taken place
  105. since the last time this command was called, so a non-zero return
  106. will indicate either a connect or disconnect, depending on the
  107. context in which the command was called.
  108.  
  109.                            **********
  110. Check to see if a particular stream is connected or not.  This is
  111. used to find a free stream for your applications!!  It is almost
  112. the same as get_status, but return the connected status of a
  113. stream.
  114.  
  115.  
  116. int far con_status(int);
  117.  
  118. int stream;
  119. int stat;
  120.  
  121. stat = con_stat(stream);
  122.  
  123.     
  124. Acknowledge the change of status, BPQ command #5.
  125.  
  126. !!!THIS COMMAND MUST be called before any other stream changes
  127. can be reported!!!
  128.  
  129. void far ack_status(int);
  130.  
  131. int stream;
  132. int stat;
  133.  
  134. stat = get_status(stream);
  135.  
  136. if (stat) {
  137.  
  138.     ack_status(stream);
  139.  
  140.     /* see what the change is */
  141.  
  142.            if (stat) {
  143.  
  144.         /* stream has connected */
  145.         
  146.         .
  147.         .
  148.  
  149.     else {
  150.  
  151.         /* stream has disconnected */
  152.  
  153.                            **********
  154.  
  155. Control the streams session type, BPQ command #6
  156. This function defines what the type of session is.
  157.  
  158. void far set_session(int, int);
  159.  
  160. #define CON_TO_NODE 1 /* Connect to the node */
  161. #define DISC        2 /* Disconnect from the node */
  162. #define RET_TO_NODE 3 /* As 2, but return the user to the node */
  163.  
  164.  
  165. int stream;
  166.  
  167. set_session(stream, DISC);
  168.  
  169. This will disconnect the user completely.
  170.  
  171.                            **********
  172.  
  173. Return the number of frames queued for receive, BPQ command #7
  174. (Part)
  175.  
  176. This function will return the number of frames waiting to be
  177. received, this is CONNECTED data, NOT monitored data( this is
  178. covered later).
  179.  
  180. int far rx_queue(int);
  181.  
  182. int stream;
  183. int rx_que_len;
  184.  
  185. rx_que_len = rx_que(stream);
  186.  
  187.                            ##########
  188.  
  189. Return the number of un-acked frames to be transmitted, BPQ
  190. command #7 (Part)
  191.  
  192. This function returns the number of unsent frames.
  193.  
  194. int far tx_queue(int);
  195.  
  196. int stream;
  197. int tx_que_len;
  198.  
  199. tx_que_len = tx_queue(stream);
  200.  
  201.                            ##########
  202.  
  203. Return the number of buffers left in the node, BPQ command #7
  204. (Part)
  205.  
  206. Returns the number of free buffers the node has left.
  207.  
  208. int far free_buffs(int);
  209.  
  210. int stream;
  211. int fre_bufs;
  212.  
  213. fre_bufs = free_buffs(stream);
  214.  
  215.                            **********
  216.  
  217. Transmit a RAW (KISS) data frame, BPQ command #10.
  218.  
  219. !!!! THIS COMMAND TRANSMITS THE FRAME ON THE RADIO PORT (not the
  220. normal 'stream') !!!!
  221.  
  222. void far raw_tx(int, int, int, int);
  223.  
  224. int radio_port;
  225. char *buffer;
  226. int length;
  227.  
  228. raw_tx(radio_port, FP_OFF(buffer), FP_SEG(buffer), length);
  229.  
  230.                            **********
  231.  
  232. Receive a RAW(KISS) frame, BPQ command 11.
  233.  
  234. This command is used for monitoring, all calls will be in AX.25
  235. format.  To enable monitoring, set bit #7 of the application flag
  236. in function #1 above.
  237.  
  238. int far raw_rx(int, int, int);
  239.  
  240. This will return the length of the received data, or 0 if none is
  241. available.
  242.  
  243. int stream;
  244. char *buffer;
  245. int raw_len;
  246.  
  247. raw_len = raw_rx(stream, FP_OFF(buffer), FP_SEG(buffer));
  248.  
  249. if (!raw_len) {
  250.     
  251.     /* No data available */
  252.  
  253. else {
  254.  
  255.     /* process the raw data */
  256.  
  257.  
  258.                            **********
  259.  
  260. Return the HOSTINTERRUPT.  This is NOT part of the BPQ commands,
  261. but has been added to make life just a bit easier!!  It assumes
  262. that the configuration file BPQCFG.BIN is in the same default
  263. directory.  This function also sets the Host interrupt, so the
  264. function set_int is not really needed, but is included for
  265. completeness.  
  266.  
  267. int far get_host(void);
  268.  
  269. Returns the host interrupt or 0 if it fails.
  270.  
  271. int BPQ_INT;
  272.  
  273. BPQ_INT = get_host();
  274.  
  275. if(!BPQ_INT) {
  276.     printf("\nError!);
  277.  
  278.                            **********
  279. This function checks to see if the switch is loaded and returns
  280. the version number, or 0 if the switch is not loaded.  This is
  281. NOT part of the BPQ  commands, just an extension here to make life
  282. easy!  The returned version number is in the form MAJOR/MINOR
  283. versions, ie, version 4.03 will be returned as 0x403 
  284.  
  285. int far check_load(void);
  286.  
  287. int loaded;
  288.  
  289. loaded = check_load();
  290.  
  291. if (!loaded) {
  292.  
  293.     /* switch not loaded! */
  294.  
  295.     else {
  296.  
  297.     /* check the version numbers! */
  298.  
  299. .
  300.  
  301. This function should be called after get_host, as that routine
  302. will have loaded the host interrupt, or failed.  This is just a
  303. further check that all is well!!
  304.  
  305.                            **********
  306.  
  307. Get the connected callsign, BPQ command #8
  308.  
  309. void far get_call(int, int, int);
  310.  
  311. This function returns the connected callsign, in ascii, which is
  312. 10 bytes, space padded.
  313.  
  314. char *buffer;
  315. int stream;
  316.  
  317. get_call(stream, FP_OFF(buffer), FP_SEG(buffer));
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.