prefect
Home Engineering Publications
DACS: Serial Communications Header, serial.h
 
  next up previous contents
Next: Serial Communications Code, serial.c Up: MIDI Controller Previous: CDROM Service Provider CD   Contents

Serial Communications Header, serial.h

This header file defines functions and structures for the serial handling code that implements the protocol described in the firmware section of this document.
/*****************************************************************************
 * DACS : Distributed Audio Control System
 *============================================================================
 *         File: serial.h
 *  Description: routines to handle serial communications with DACS components
 *       Author: Stephen S. Richardson
 * Date Created: 07.12.97
 *  Environment: GNU C Compiler (GCC) v2.7.1, Linux i486 v2.0.28
 *        Build: library
 *============================================================================
 * The code, executables, documentation, firmware images, and all related
 * material of DACS are  
 * Copyright (C) 1997 Stephen S. Richardson - ALL RIGHTS RESERVED
 *****************************************************************************
 * Source code control:
 *
 * $Id: serial.h,v 1.1 1997/07/25 12:09:25 prefect Exp prefect $
 *
 *****************************************************************************/

#define SERBUFLEN 1024                         /* serial buffer size */

#define MAXPAYLOAD 128                         /* maximum payload size */
#define MAXFRSIZE  MAXPAYLOAD+MAXPAYLOAD+4     /* maximum frame size */

#define DLE  '!'                 /* data link escape character 0x10 */
#define STX  '['                 /* start transmission 0x02 */
#define ETX  ']'                 /* end transmission 0x03 */


struct serbuf {
  char data[SERBUFLEN];          /* data in buffer */
  int len;                       /* current length of buffer */
  int cur;                       /* index to current data in buffer */
};


struct raw_frame {
  int len;                       /* length of frame */
  int cur;                       /* current index */
  char data[MAXPAYLOAD];         /* frame data */
  char done;                     /* done flag */
  char dleflag;                  /* DLE flag */
  char stxflag;                  /* STX flag */
};


void ser_init_frame (struct raw_frame *f);
void ser_init_serbuf (struct serbuf *b);
int ser_write_buf (struct raw_frame *fr, struct serbuf *ob);
int ser_open (char *devnam, int bd);
int ser_service (struct serbuf *ib, struct serbuf *ob,
		 struct raw_frame *of, int serfd);


Steve Richardson 2000-07-06
Table of Contents

[PDF] [Whole document in PDF 1.9MB]

[more photos and information]

 
Page last modified:
Copyright © 1993-2000 prefect - All Rights Reserved.