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

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

Various minor bug fixes and improvements to the serial server code.

File size: 1.4 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 { 76800, 0x2, "76.8K", "77K" },
20 { 115200, 0x3, "115.2K", "115K" },
21 { 153600, 0x3, "153.6K", "154K" },
22 { 230400, 0xff, "230.4K", "230K" },
23 { 460800, 0x1, "460.8K", "460K" },
24 { 0, 0, NULL, NULL }
25};
26
27struct baudRate *baudRateMatchString( char *str )
28{
29 struct baudRate *b;
30
31 unsigned long a = atol( str );
32 if( a )
33 {
34 for( b = supportedBaudRates; b->rate; b++ )
35 if( b->rate == a )
36 return( b );
37 }
38
39 for( b = supportedBaudRates; b->rate; b++ )
40 if( !stricmp( str, b->display ) || (b->altSelection && !stricmp( str, b->altSelection )) )
41 return( b );
42
43 return( NULL );
44}
45
46struct baudRate *baudRateMatchDivisor( unsigned char divisor )
47{
48 struct baudRate *b;
49
50 for( b = supportedBaudRates; b->rate && b->divisor != divisor; b++ )
51 ;
52
53 return( b->rate ? b : NULL );
54}
55
56
Note: See TracBrowser for help on using the repository browser.