Changeset 211 in xtideuniversalbios for trunk


Ignore:
Timestamp:
Jan 16, 2012, 7:23:11 PM (13 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

More minor changes, improved usage message

Location:
trunk/Serial_Server
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Serial_Server/library/FlatImage.cpp

    r209 r211  
    2525        fp = fopen( name, "r" );
    2626        if( fp )
    27             log( 0, "Create Failure: '%s' already exists", name );
     27            log( -1, "Create Failure: '%s' already exists", name );
    2828       
    2929        if( !(fp = fopen( name, "w" )) )
    30             log( 0, "Could not create file '%s'", name );
     30            log( -1, "Could not create file '%s'", name );
    3131
    3232        memset( &buff[0], 0, 512 );
     
    3535        {
    3636            if( fwrite( &buff[0], 1, 512, fp ) != 512 )
    37                 log( 0, "Create write black sector error" );
     37                log( -1, "Create write black sector error" );
    3838        }
    3939        fclose( fp );
    4040       
    4141        sizef = size2/2048.0;
    42         log( 1, "Created file '%s' with geometry %u:%u:%u, size %.1lf megabytes\n", name, p_cyl, p_sect, p_head, sizef );
     42        log( 0, "Created file '%s' with geometry %u:%u:%u, size %.1lf megabytes\n", name, p_cyl, p_sect, p_head, sizef );
    4343    }
    4444
    4545    fp = fopen( name, "r+" );
    4646    if( !fp )
    47         log( 0, "Could not Open %s", name );
    48 
    49     log( 1, "Opening disk image '%s'", name );
     47        log( -1, "Could not Open '%s'", name );
    5048
    5149    fseek( fp, 0, SEEK_END );
     
    5351
    5452    if( !totallba )
    55         log( 0, "Could not get file size" );
     53        log( -1, "Could not get file size for '%s'", name );
    5654
    5755    if( totallba & 0x1ff )
    58         log( 0, "File not made up of 512 byte sectors" );
     56        log( -1, "'%s' not made up of 512 byte sectors", name );
    5957
    6058    totallba >>= 9;
     
    6260    {
    6361        if( p_sect || p_head || p_cyl )
    64             log( 0, "File size does not match geometry" );
     62            log( -1, "'%s', file size does not match geometry", name );
    6563        else if( (totallba % 16) != 0 || ((totallba/16) % 63) != 0 )
    66             log( 0, "File size does not match standard geometry (x:16:63), please give explicitly with -g" );
     64            log( -1, "'%s', file size does not match standard geometry (x:16:63), please geometry explicitly with -g", name );
    6765        else
    6866        {
     
    8078
    8179    sizef = totallba/2048.0;
    82     log( 1, "Using geometry %u:%u:%u, total size %.1lf megabytes", cyl, sect, head, sizef );
     80    log( 0, "Opening disk image '%s', geometry %u:%u:%u, total size %.1lf MB", name, cyl, sect, head, sizef );
    8381}
    8482
  • trunk/Serial_Server/library/Image.cpp

    r209 r211  
    3333
    3434    if( *(shortFileName) == 0 )
    35         log( 0, "Can't parse %s\n\n", name );
     35    {
     36        log( 1, "Can't parse '%s' for short file name\n\n", name );
     37        shortFileName = "SerDrive";
     38    }
    3639 
    3740    readOnly = p_readOnly;
  • trunk/Serial_Server/library/Process.cpp

    r210 r211  
    6868            sprintf( &logBuff[logCount*9], "... " );
    6969
    70         log( 4, "%s%s", message, logBuff );
     70        log( 3, "%s%s", message, logBuff );
    7171    }
    7272}
     
    118118            len = 1;
    119119            workCount = 0;
    120             log( 2, "Timeout waiting on command" );
     120            log( 1, "Timeout waiting on command" );
    121121            continue;
    122122        }
     
    149149                {
    150150                    if( buff.b[0] >= 0x20 && buff.b[0] <= 0x7e )
    151                         log( 3, "Spurious: [%d:%c]", buff.b[0], buff.b[0] );
     151                        log( 2, "Spurious: [%d:%c]", buff.b[0], buff.b[0] );
    152152                    else
    153                         log( 3, "Spurious: [%d]", buff.b[0] );
     153                        log( 2, "Spurious: [%d]", buff.b[0] );
    154154                }
    155155                buffoffset = 0;
     
    172172            if( (crc = checksum( &buff.w[0], 256 )) != buff.w[256] )
    173173            {
    174                 log( 1, "Bad Write Sector Checksum" );
     174                log( 0, "Bad Write Sector Checksum" );
    175175                continue;
    176176            }
     
    178178            if( img->readOnly )
    179179            {
    180                 log( 2, "Attempt to write to read-only image" );
     180                log( 1, "Attempt to write to read-only image" );
    181181                continue;
    182182            }
     
    189189            //
    190190            if( serial->writeCharacters( &buff.w[256], 2 ) != 2 )
    191                 log( 1, "Serial Port Write Error" );
     191                log( 0, "Serial Port Write Error" );
    192192
    193193            workOffset++;
     
    209209                if( buff.b[0] != (workCount-0) )
    210210                {
    211                     log( 1, "Continue Fault: Received=%d, Expected=%d", buff.b[0], workCount );
     211                    log( 0, "Continue Fault: Received=%d, Expected=%d", buff.b[0], workCount );
    212212                    workCount = 0;
    213213                    continue;
     
    221221                if( (crc = checksum( &buff.w[0], 3 )) != buff.w[3] )
    222222                {
    223                     log( 1, "Bad Command Checksum: %02x %02x %02x %02x %02x %02x %02x %02x, Checksum=%02x",
     223                    log( 0, "Bad Command Checksum: %02x %02x %02x %02x %02x %02x %02x %02x, Checksum=%02x",
    224224                         buff.b[0], buff.b[1], buff.b[2], buff.b[3], buff.b[4], buff.b[5], buff.b[6], buff.b[7], crc);
    225225                    continue;
     
    230230                    if( !image1 )
    231231                    {
    232                         log( 2, "Slave drive selected when not supplied" );
     232                        log( 1, "Slave drive selected when not supplied" );
    233233                        img = NULL;
    234234                        continue;
     
    261261                if( (workCommand & SERIAL_COMMAND_WRITE) && img->readOnly )
    262262                {
    263                     log( 2, "Write attempt to Read Only disk" );
     263                    log( 1, "Write attempt to Read Only disk" );
    264264                    continue;
    265265                }
     
    293293
    294294                        if( br )
    295                             log( 2, "    Ignoring Inquire with Baud Rate=%d", br->rate );
     295                            log( 1, "    Ignoring Inquire with Baud Rate=%d", br->rate );
    296296                        else
    297                             log( 2, "    Ignoring Inquire with Unknown Baud Rate (portAndBaud=%d)", buff.inquire.portAndBaud );
     297                            log( 1, "    Ignoring Inquire with Unknown Baud Rate (portAndBaud=%d)", buff.inquire.portAndBaud );
    298298                        workCount = 0;
    299299                        continue;
     
    314314
    315315                if( serial->writeCharacters( &buff.w[0], 514 ) != 514 )
    316                     log( 1, "Serial Port Write Error" );
     316                    log( 0, "Serial Port Write Error" );
    317317
    318318                workCount--;
     
    327327
    328328            if( vtype == 1 )
    329                 log( 2, "%s %d: LBA=%u, Count=%u", comStr, img == image0 ? 0 : 1,
     329                log( 1, "%s %d: LBA=%u, Count=%u", comStr, img == image0 ? 0 : 1,
    330330                     mylba, workCount );
    331331            else if( vtype == 2 )
    332                 log( 2, "%s %d: Cylinder=%u, Sector=%u, Head=%u, Count=%u, LBA=%u", comStr, img == image0 ? 0 : 1,
     332                log( 1, "%s %d: Cylinder=%u, Sector=%u, Head=%u, Count=%u, LBA=%u", comStr, img == image0 ? 0 : 1,
    333333                     cyl, sect, head, workCount+1, mylba );
    334334
     
    336336
    337337            if( workOffset > 1 )
    338                 log( 3, "    Continuation: Offset=%u, Checksum=%04x", workOffset-1, buff.w[256] );
     338                log( 2, "    Continuation: Offset=%u, Checksum=%04x", workOffset-1, buff.w[256] );
    339339
    340340            if( !(workCommand & SERIAL_COMMAND_WRITE) && verboseLevel >= 4 )
     
    342342
    343343            if( workCount == 0 && workOffset > 100 )
    344                 log( 2, "    Block Complete: %.2lf bytes per second", (512.0 * workOffset) / (GetTime() - perfTimer) * 1000.0 );
     344                log( 1, "    Block Complete: %.2lf bytes per second", (512.0 * workOffset) / (GetTime() - perfTimer) * 1000.0 );
    345345        }
    346346    }
  • trunk/Serial_Server/makefile

    r209 r211  
    1313WIN32OBJS = build/win32.obj build/win32serial.obj build/checksum.obj build/serial.obj build/flatimage.obj build/process.obj build/image.obj
    1414
    15 build/serserve.exe: $(WIN32OBJS)
    16     $(CL) /Febuild/serserve.exe $(WIN32OBJS)
     15build/serdrive.exe: $(WIN32OBJS)
     16    $(CL) /Febuild/serdrive.exe $(WIN32OBJS)
    1717
    1818build/%.obj:    win32/%.cpp
  • trunk/Serial_Server/win32/Win32.cpp

    r209 r211  
    2121{
    2222    char *usageStrings[] = {
    23         "usage: SerServe [options] master-imagefile [[slave-options] slave-imagefile]",
     23        "SerDrive - XTIDE Universal BIOS Serial Drive Server",
     24        "Version 1.2.0_wip, Built " __DATE__,
     25        "",
     26        "usage: SerDrive [options] imagefile [[slave-options] slave-imagefile]",
     27        "",
    2428        "  -g cyl:sect:head  Geometry in cylinders, sectors per cylinder, and heads",
    2529        "                    (default is 65:63:16 for a 32 MB disk)",
    26         "  -n [megabytes]    New, Create new disk with given size or use -g geometry",
    27         "  -p                Named pipe mode for emulators (pipe is " PIPENAME ")",
    28         "  -c PortNumber     COM Port to use (default is first found)",
     30        "",
     31        "  -n [megabytes]    Create new disk with given size or use -g geometry",
     32        "",
     33        "  -p                Named Pipe mode for emulators (pipe is '" PIPENAME "')",
     34        "",
     35        "  -c COMPortNumber  COM Port to use (default is first found)",
     36        "",
    2937        "  -b BaudRate       Baud rate to use on the COM port ",
    30         "                    9600, 38400, 115200, 230400, or 460800",   
    31         "                    (default 9600, 115200 in pipe mode)",
     38        "                    Without a rate multiplier: 2400, 9600, 38400, 115200",
     39        "                    With a 2x rate multiplier: 4800, 19200, 76800, 230400",
     40        "                    With a 4x rate multiplier: 9600, 38400, 153600, 460800",
     41        "                    Abbreviations also accepted (ie, '460K', '38.4K', etc)",
     42        "                    (default is 9600, 115200 in named pipe mode)",
     43        "",
    3244        "  -t                Disable timeout, useful for long delays when debugging",
    33         "  -r                Read Only disk",
    34         "  -v [level]        Reporting level 1-6, increasing information",
     45        "",
     46        "  -r                Read Only disk, do not allow writes",
     47        "",
     48        "  -v [level]        Reporting level 1-6, with increasing information",
    3549        NULL };
    3650
     
    4155}
    4256
    43 int verbose = 1;
     57int verbose = 0;
    4458
    4559int main(int argc, char* argv[])
     
    158172
    159173        if( serial->resetConnection )
    160             log( 1, "==== Resetting Connection ====" );
     174            log( 0, "Connection closed, reset..." );
    161175    }
    162176    while( serial->resetConnection );
     
    169183    va_start( args, message );
    170184
    171     if( level == 0 )
    172     {
    173       vfprintf( stderr, message, args );
    174       fprintf( stderr, "\n" );
    175       exit( 1 );
     185    if( level < 0 )
     186    {
     187        fprintf( stderr, "ERROR: " );
     188        vfprintf( stderr, message, args );
     189        fprintf( stderr, "\n" );
     190        exit( 1 );
    176191    }
    177192    else if( verbose >= level )
    178193    {
    179       vprintf( message, args );
    180       printf( "\n" );
     194        vprintf( message, args );
     195        printf( "\n" );
    181196    }
    182197
  • trunk/Serial_Server/win32/Win32Serial.cpp

    r209 r211  
    4040        }
    4141        if( !name )
    42             log( 0, "No Physical COM Ports Found" );
     42            log( -1, "No physical COM ports found" );
    4343    }
    4444
    4545    if( !strcmp( name, "PIPE" ) )
    4646    {
    47         log( 1, "Opening named pipe %s (simulating %lu baud)", PIPENAME, baudRate->rate );
     47        log( 0, "Opening named pipe %s (simulating %lu baud)", PIPENAME, baudRate->rate );
    4848       
    4949        pipe = CreateNamedPipeA( PIPENAME, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_REJECT_REMOTE_CLIENTS, 2, 1024, 1024, 0, NULL );
    5050        if( !pipe )
    51             log( 0, "Could not CreateNamedPipe " PIPENAME );
     51            log( -1, "Could not CreateNamedPipe " PIPENAME );
    5252       
    5353        if( !ConnectNamedPipe( pipe, NULL ) )
    54             log( 0, "Could not ConnectNamedPipe" );
     54            log( -1, "Could not ConnectNamedPipe" );
    5555
    5656        speedEmulation = 1;
     
    6161        if( QueryDosDeviceA( name, buff2, sizeof(buff2) ) )
    6262        {
    63             log( 1, "Opening %s (%lu baud)", name, baudRate->rate );
     63            log( 0, "Opening %s (%lu baud)", name, baudRate->rate );
    6464           
    6565            pipe = CreateFileA( name, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 );
    6666            if( !pipe )
    67                 log( 0, "Could not Open \"%s\"", name );
     67                log( -1, "Could not Open \"%s\"", name );
    6868           
    6969            FillMemory(&dcb, sizeof(dcb), 0);
     
    7474            dcb.Parity = NOPARITY;
    7575            if( !SetCommState( pipe, &dcb ) )
    76                 log( 0, "Could not SetCommState" );
     76                log( -1, "Could not SetCommState" );
    7777
    7878            if( !SetCommTimeouts( pipe, &timeouts ) )
    79                 log( 0, "Could not SetCommTimeouts" );
     79                log( -1, "Could not SetCommTimeouts" );
    8080        }
    8181        else
    8282        {
    83             int first = 1;
    8483            char logbuff[ 1024 ];
    85             sprintf( logbuff, "Serial Port Not Found \"%s\", Available: ", name );
    86             for( int t = 1; t <= 30 && !name; t++ )
     84            int found = 0;
     85
     86            sprintf( logbuff, "serial port '%s' not found, detected COM ports:", name );
     87
     88            for( int t = 1; t <= 40; t++ )
    8789            {
    8890                sprintf( buff1, "COM%d", t );
    8991                if( QueryDosDeviceA( buff1, buff2, sizeof(buff2) ) )
    9092                {
    91                     if( !first )
    92                         strcat( logbuff, ", " );
    93                     else
    94                         first = 0;
     93                    strcat( logbuff, "\n    " );
    9594                    strcat( logbuff, buff1 );
     95                    found = 1;
    9696                }
    9797            }
    98             log( 0, logbuff );
     98            if( !found )
     99                strcat( logbuff, "\n    (none)" );
     100
     101            log( -1, logbuff );
    99102        }
    100103    }
Note: See TracChangeset for help on using the changeset viewer.