none
CMD Redirection to Serial RRS feed

  • Question

  • Hi,

    I am trying to redirect Console to UART. For this I have written a AutoLaunch application which will do the following

    • Change Baud rate to 115200 and Disable DTR and RTS

    Platform.reg settings are

    ;Console Redirection

    [HKEY_LOCAL_MACHINE\Drivers\Console]

    "OutPutTo"=dword:1

    "COMSpeed"=dword:1C200

    ;-- Launch auto launch application at run time

    [HKEY_LOCAL_MACHINE\init]

    "Launch100"="autolaunch.exe"

    Autolaunch source code is

    hPort = CreateFile(szDeviceName,

    // Pointer to the name of the port

    GENERIC_READ | GENERIC_WRITE,

    // Access (read-write) mode

    0,

    // share mode

    NULL,

    // pointer to the security attribute

    OPEN_EXISTING,

    // how to open the serial port

    FILE_ATTRIBUTE_NORMAL,

    // Port attributes

    NULL

    // Handle to port with attribute to copy

    );

     

    if

    ( hPort == INVALID_HANDLE_VALUE )

    {

    RETAILMSG(1, (TEXT(

    "\r\nAutoLaunch: Unable to open COM port:-> %s %d \r\n"

    ),szDeviceName, GetLastError()));

     

    return

    FALSE;

    }

    ZeroMemory (&ProcInfo,

    sizeof

    (PROCESS_INFORMATION));

    GetCommState(hPort, &PortDCB);

    // Get the Port Info

    PortDCB.BaudRate = CBR_115200 ;

    // Baud Rate = 1,15,200

    PortDCB.fDtrControl = DTR_CONTROL_DISABLE;

    PortDCB.fRtsControl = RTS_CONTROL_DISABLE;

     

    if(0 == SetCommState(hPort, &PortDCB))

    // Configure Port

    {

    ERRORMSG(TRUE, (TEXT(

    "\r\nAutoLaunch:Unable to configure %s port Err %d \r\n"

    ), szDeviceName, GetLastError()));

    CloseHandle (hPort);

     

    return

    FALSE;

    }

     

    if

    (!CloseHandle (hPort))

    {

    ERRORMSG (1,(L

    "CloseHandle Failed for Serial Port\r\n"

    ));

    }

    bRetVal = CreateProcess( L

    "cmd.exe", L"/K"

    , NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, NULL, &ProcInfo);

    As soon as CreateProcess executes I see so many DEBUGCHK failures on UART.

    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    KITL(1): Tossing frame 9 (Can't signal Rx event)
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568
    NK Kernel: DEBUGCHK failed in file d:\yzkiqfe\private\winceos\COREOS\nk\kernel\n
    knormal\..\vm.c at line 3568

    Is this is not correct way of redirecting Console onto UART?

    Let me know if my procedure is wrong.

    Thank You & Regards,

    GSR

     
    Monday, August 22, 2011 6:23 AM

All replies