LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to capture output to DOS Window

I'm writing an application to program an Atmel AVR, and then run a test routine on my board.  Atmel provides the tool for the programming and I'm using the following command:
 
LaunchExecutable("Stk500 -cUSB -dATmega128 -e -ifFlashFile.hex -pf -vf");
 
This works great - but the STK500.exe executable sends all of it's status and error messages to a standard DOS window.  The output is:
Setting mode and device parameters.. OK!
Entering programming mode.. OK!
Erasing device.. OK!
Programming FLASH ..      OK!
Reading FLASH ..      OK!
FLASH contents is equal to file.. OK
Leaving programming mode.. OK!
 
 
I need to capture this output so I can have my application verify that the programming was done, and is correct before proceeding with the test.
 
I'm fine with dumping STK500.exe's output to a file and then parsing the file, grabbing the output and sending it to a text box would be even better.  I just can't figure out how to make CVI 6.0 redirect these messages from the DOS window to anywhere I can access them.
 
Any Suggestions?
0 Kudos
Message 1 of 8
(7,454 Views)
Use the DOS redirect operator '>'. Like this:

    LaunchExecutable("cmd /c Stk500 -cUSB -dATmega128 -e -ifFlashFile.hex -pf -vf > logfile.txt");

JR
Message 2 of 8
(7,450 Views)
JR - Thanks that works great.  I knew there was a simple way.
0 Kudos
Message 3 of 8
(7,447 Views)
Hi guys, I have another similar problem - how to get the error code from DOS application. That's easy with labview, but CVI returns only CVI based errorcodes and not the error return code of DOS application.
0 Kudos
Message 4 of 8
(6,966 Views)
Hello Baca,

I'm not sure what you are talking about.  Tell me how you are doing this in LabVIEW and I'll try to figure out a way to do it in CVI.


Kristen
National Instruments
0 Kudos
Message 5 of 8
(6,924 Views)

hi ,

you means batch file error code? I have used this .bat file for download.

based batch file:

@rem Drive a Atmel AVRISP connected to serial port specified in first command line parameter
@rem to load software into a R3048 Secondary Control board containing an ATmega32
@cls

@title Programming NPR Secondary Control Board

@rem Load S/W specified in second command line parameter
@echo Programming NPR Secondary Control Board ATmega32 uC with %2
@echo.

@rem stk500.exe -c%1 -ms -dATmega32 -if%2  -e -pf -vf -f0xC43F -l0xFF
@stk500.exe -c%1 -ms -dATmega32 -if%2  -e -pf -vf -f0xC41F -l0xFF
@rem -c    Com Port
@rem -ms   Mode Serial
@rem -d..  Device = ATMega32
@rem -if.. In Flash file
@rem -e    Erase
@rem -pf   Program Flash
@rem -vf   Verify Flash
@rem
@rem -f    Program Flag bits

@rem 0xCF1F = b  1  1  0  0  0  1  0  0  0  0  1  1  1  1  1  1

@rem           |15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00|
@rem            |  |  |  |  |  |  |  |  |  |  |  |  +--+--+--+-- CKSEL3-CKSEL0 (Clock Select)
@rem            |  |  |  |  |  |  |  |  |  |  +--+-------------- SUT1 - SUT0
@rem            |  |  |  |  |  |  |  |  |  +-------------------- BODEN (Brown Out Dectection Enable [0 Enable, 1 Disable])
@rem            |  |  |  |  |  |  |  |  +----------------------- BODLEVEL (Brown Out Dectection Level [0 = 4.0V, 1 = 2.7V])
@rem            |  |  |  |  |  |  |  +-------------------------- BOOTRST (Boot Loader Support [1 start at $0000, 0 start in bootloader])
@rem            |  |  |  |  |  +--+----------------------------- BOOTSZ1 & BOOTSZ0 (Boot loader size [00=2048words, 01=1024words, 10=512words, 11=256words])
@rem            |  |  |  |  +----------------------------------- EESAVE (Preserve EEprom during erase cycle [0 Preserve, 1 Do not Presesve])
@rem            |  |  |  +-------------------------------------- CKOPT (0 Full rail-to-rail output swing)
@rem            |  |  +----------------------------------------- SPIEN (SPI Programming interface Enable [0 Enable, 1 Disable])
@rem            |  +-------------------------------------------- JTAGEN (JTAG Enable [0 Enable, 1 disable])
@rem            +----------------------------------------------- OCDEN (On Chip Debug Enable [0 Enable, 1 Disable])


@rem Flag bits specify use of external crystal oscillator at nominal 4 MHz with Brown-out detection enabled

@rem -l    Program Lock bits

@rem           |07|06|05|04|03|02|01|00|
@rem            |  |  |  |  |  |  +--+-------------------------- LB2 & LB1 (Flash Lock Bits)
@rem            |  |  |  |  +--+-------------------------------- BLB02 & BLB01 (Boot0 Lock Bits)
@rem            |  |  +--+-------------------------------------- BLB12 & BLB11 (Boot1 Lock Bits)
@rem            +--+-------------------------------------------- Unused Set to 1

@rem returns an errorlevel of 0 on success and 1 for an error

@echo.
@echo.
@echo.

@if ERRORLEVEL 1 goto failed

@echo.======================================================================
@echo.=====================PROGRAMMING SUCESSFUL============================
@echo.======================================================================

@rem Dummy stream operation to ensure ERRORLEVEL is set to 0
@ver > NUL

@goto end
:failed
@echo.**********************************************************************
@echo.*********************PROGRAMMING FAILED!!!!!**************************
@echo.**********************************************************************

@rem Dummy copy to ensure ERRORLEVEL is set to 1
@copy nonexistantFile.txt \\computer\share\file.txt > NUL

:end
@echo.

your app batch file:

@rem Replace x.xx with actual version number of file to use and if necessary qualify path

@call "APRApplicationLoad for ATmega32.bat" USB "........ .a90"

echo %errorlevel% > result.txt

Sonic

Diffrent Strokes for Different Folks
0 Kudos
Message 6 of 8
(6,883 Views)
Hi, there is System Exec function in LabVIEW, which returns Standart output, Standard error and Error code (see LabVIEW help for details). In CVI I have to create a batch file, redirect output of the DOS application to text file (for example batchISP.exe > debug.txt), redirect error codes to another text file (echo %errorlevel% > error.txt), load both textfiles and only then work with that. Is that a common way how to do that in CVI?
0 Kudos
Message 7 of 8
(6,881 Views)
Hello Baca,

I've looked into this and we do not have any CVI functions to do what you are wanting, easier than the way you are already doing it.  I also looked into the ANSI C function system() (included in stdlib.h) but I could not find anything about what you want using that either.

If you want there is a link to a page where you can give feedback here and suggest that they include a function like the System Exec VI in CVI.
Kristen
National Instruments
0 Kudos
Message 8 of 8
(6,851 Views)