home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_03 / 9n03041a < prev    next >
Text File  |  1991-01-22  |  2KB  |  76 lines

  1. /******************************************************
  2.  * NAME       : message_out
  3.  *
  4.  * DESCRIPTION:
  5.  *    waits for a message in the message out queue,
  6.  *    when  one appears it assembles it then sends it.
  7.  ******************************************************/
  8.  
  9. #include "que.h"
  10.  
  11. extern struct g_queue out_que;
  12. unsigned char buf[32];
  13.  
  14. void message_out()
  15. {
  16.    unsigned char no_msg_out,length;
  17.    int i;
  18.  
  19.    while (true)
  20.    {
  21.       length = remove_one(&out_que);
  22.       buf[0] = length;
  23.       for(i=1; i<=length; i++)
  24.          buf[i] = remove_one(&out_que);
  25.       format_msg();
  26.       send_msg();
  27.    }
  28. }
  29.  
  30. /********************************************************
  31.  * NAME: format_msg
  32.  *
  33.  * DESCRIPTION: takes a message in the buffer and
  34.  *              formats it for the serial port.
  35.  *******************************************************/
  36.  
  37. format_msg()
  38. {
  39.    /* prepare a buffer for crc generation */
  40.  
  41.    /* now calculate the CRC */
  42.  
  43.    /* insert the crc bytes into the buffer */
  44.  
  45.    /* now add the DLE characters */
  46.  
  47.    /* add the stop flag */
  48.  
  49.    /* now check the CRC characters to see if we should add DLE's */
  50.  
  51.    /* finally - put in the length of total buffer */
  52.  
  53. }
  54.  
  55.  
  56. /*********************************************************************
  57.  *
  58.  * NAME       : send_msg
  59.  *
  60.  * */
  61.  
  62. send_msg()
  63. {
  64.    /* send the first character to the serial port to kick off the
  65.       serial transmission.  turn on the interupts and let the interrupts
  66.       finish the rest of the transmission   */
  67.  
  68.    /* now turn on the serial transmit buffer */
  69.  
  70.    /* send the first character to the serial transmit buffer */
  71.  
  72.    /* enable the interrupt for serial transmit data register empty */
  73.  
  74.    /* wait for the last character to be completely transmitted */
  75. }
  76.