source: xtideuniversalbios/trunk/Serial_Server/library/Serial.cpp@ 209

Last change on this file since 209 was 209, checked in by gregli@…, 13 years ago

Initial checkin for the Serial Server code, to be run on a host computer with a hard disk image file. Connected via a serial line, this provides the I/O for the serial port support in the XTIDE bios. At present, this is a Win32 command line program, run without parameters for usage information.

File size: 1.3 KB
Line 
1//======================================================================
2//
3// Project: XTIDE Universal BIOS, Serial Port Server
4//
5// File: Serial.cpp - Generic functions for dealing with serial communications
6//
7
8#include "library.h"
9#include <stdlib.h>
10#include <string.h>
11
12struct baudRate supportedBaudRates[] =
13{
14 { 2400, 0x0, "2400", NULL },
15 { 4800, 0xff, "4800", NULL },
16 { 9600, 0x1, "9600", NULL },
17 { 19200, 0xff, "19.2K", "19K" },
18 { 38400, 0x2, "38.4K", "38K" },
19 { 115200, 0x3, "115.2K", "115K" },
20 { 230400, 0xff, "230.4K", "230K" },
21 { 460800, 0x1, "460.8K", "460K" },
22 { 0, 0, NULL, NULL }
23};
24
25struct baudRate *baudRateMatchString( char *str )
26{
27 struct baudRate *b;
28
29 unsigned long a = atol( str );
30 if( a )
31 {
32 for( b = supportedBaudRates; b->rate; b++ )
33 if( b->rate == a )
34 return( b );
35 }
36
37 for( b = supportedBaudRates; b->rate; b++ )
38 if( !stricmp( str, b->display ) || (b->altSelection && !stricmp( str, b->altSelection )) )
39 return( b );
40
41 return( NULL );
42}
43
44struct baudRate *baudRateMatchDivisor( unsigned char divisor )
45{
46 struct baudRate *b;
47
48 for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ )
49 ;
50
51 return( b->rate ? b : NULL );
52}
53
54
Note: See TracBrowser for help on using the repository browser.