Forum > Unix
How to run AVRDUDE in commandline FPC application
pascalbythree:
Hey Brothers,
Does anybody know how to start AVRDUDE in a command line application?
First: the text lines from avrdude do have to show up in console itself, but then with a #10#13 at the end. With does not work, see attachment.
Second: If the AVRDUDE application ends my own FPC console executable has to continue.
Anybody knows a small code example with right options ?
Greets, Wouter van Wegen
or a SSH command line parameter?
or try a FPC command to the console it is running in, to try?
where do i have to google on? #10 #13 is called linefeed? or wat is the original term
MarkMLl:
So what are you actually doing: invoking AvrDude from inside a custom program that you've written (I'm trying to distinguish this case from your simply bundling them up in a shell script)? If so how are you invoking it: show your code. Assuming Linux rather than something really weird, what happens if instead of running AvrDude you run something like ls? Is it an off-the-shelf AvrDude, or have you built it from scratch?
MarkMLl
prof7bit:
This might serve as inspiration.
(copy-pasted from own code for similar purpose, stripped down to the relevant parts)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var B: Byte; Line: String = ''; // snip begin // snip FProc.Options := [poUsePipes, poStderrToOutPut, poNoConsole]; try FProc.Execute; TimeOut := Now + TimeOutSeconds * SECOND; repeat while FProc.Output.NumBytesAvailable > 0 do begin FProc.Output.Read(B{%H-}, 1); if B = 8 then // the JLink commander sometimes sending backspace Setlength(Line, (Length(Line) - 1)) else begin Line += chr(B); if RightStr(Line, Length(LineEnding)) = LineEnding then begin; Line := Trim(Line); Print(Line); Line := ''; end; end; end; if Assigned(IdleMethod) then IdleMethod; until not FProc.Running or (Now > TimeOut); if FProc.Running then begin Print(rsTimeout); FProc.Terminate(1); Result := 1; end else Result := FProc.ExitCode; // snip
As IdleMethod I have Application.ProcessMessages to not freeze the UI during these 5 seconds the process takes to run and instead of Print() (which in my program is a method to add the lines to a memo so I can watch them scrolling by in realtime) you can add them to a string list.
Basically I read from the Pipe byte by byte until a line ending occurs, then it knows it has a line complete, processes it and empties the line again.
The above code is part of a component I once wrote whose sole purpose is to run this tool, I use it sometimes in GUI apps, sometimes in console apps, so I can assign the idle method (if it is GUI) or just leave it away if it is a command line app that is allowed to block its main thread.
The Print() method will also call a callback that I can supply or otherwise it will just writeln to stdout.
pascalbythree:
Is this code for UnTerminal-1.0 or is it default FPC linux code?
I am now working to compile it.
pascalbythree:
yay! it got towork i think! thank you all! I am now going to implement the snippet code into my own console application! Greets Wouter
incase new problems, i will be back.
Navigation
[0] Message Index
[#] Next page