pub.freeporcess
BlitzMax Forums/BlitzMax Programming/pub.freeporcess
| ||
The following problem again: I need the console output from avrdude in my blitzmax app. The problem is now that not the the process does not work if i use to read the flash the blitzmax app crashes.(uncomment the 3 line) if i use the the other command for output the console help it works. Import pub.freeprocess 'Local temp_proc:tproc = CreateProc("./avrdude -p atmega32 -c usbasp -Uflash:r:test.hex:i",1) Local temp_proc:tproc = CreateProc("./avrdude -?",1) While temp_proc.Eof() = False If temp_proc.pipeavail() Print "pipe: " + temp_proc.readpipe() If temp_proc.erravail() Print "err: " + temp_proc.readerr() Wend temp_proc.close() Type tproc Extends TProcess Method close:Int() Super.close() terminate() End Method Method avail:Int() Return err.bufferpos Or err.readavail() Or pipe.bufferpos Or pipe.readavail() End Method Method read:String() If err.bufferpos > 0 Or err.readavail() > 0 Return err.ReadLine().Replace("~r","").Replace("~n","") If pipe.bufferpos > 0 Or pipe.readavail() > 0 Return pipe.ReadLine().Replace("~r","").Replace("~n","") End Method Method readpipe:String() If pipe.bufferpos > 0 Or pipe.readavail() > 0 Return pipe.ReadLine().Replace("~r","").Replace("~n","") End Method Method readerr:String() If err.bufferpos > 0 Or err.readavail() > 0 Return err.ReadLine().Replace("~r","").Replace("~n","") End Method Method pipeavail:Int() Return pipe.bufferpos Or pipe.readavail() End Method Method erravail:Int() Return err.bufferpos Or err.readavail() End Method Method Eof:Int() If status() = 1 Return False If pipe.readavail() > 0 Return False If err.readavail() > 0 Return False If pipe.bufferpos > 0 Return False If err.bufferpos > 0 Return False Return True End Method Function Create:TProc(ncmd:String,nflags:Int) Local temp_proc:TProc Local infd,outfd,errfd 'do mac speciffic stuff ?MacOS If FileType(ncmd)=2 ncmd :+ "/Contents/MacOS/" + StripExt(StripDir(ncmd)) EndIf ? 'create the proc object temp_proc = New TProc 'setup the proc temp_proc.name = ncmd 'attempt to start the process temp_proc.handle = fdProcess(ncmd,Varptr(infd),Varptr(outfd),Varptr(errfd),nflags) If Not temp_proc.handle Return Null 'creat teh process pipes temp_proc.pipe = TPipeStream.Create(infd,outfd) temp_proc.err = TPipeStream.Create(errfd,0) 'add process to process list If Not ProcessList ProcessList = New TList ProcessList.AddLast temp_proc 'return the proc object Return temp_proc End Function End Type Function CreateProc:tproc(ncmd:String,nhidden:Int = True) Return tproc.Create(ncmd,nhidden) End Function Here is the Crashreport: Process: test1 [3012] Path: /Applications/BlitzMax/*/test1.app/Contents/MacOS/test1 Identifier: test1 Version: ??? (???) Code Type: X86 (Native) Parent Process: bmk [3003] Date/Time: 2012-06-09 09:40:07.000 +0200 OS Version: Mac OS X 10.7.4 (11E53) Report Version: 9 Interval Since Last Report: 1008852 sec Crashes Since Last Report: 134 Per-App Crashes Since Last Report: 5 Anonymous UUID: 843D94F3-F604-4889-BDBA-D6613FA11749 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000000007fffff VM Regions Near 0x7fffff: __LINKEDIT 000000000076b000-0000000000778000 [ 52K] r--/rwx SM=COW /System/Library/Frameworks/OpenAL.framework/Versions/A/OpenAL --> MALLOC_SMALL 0000000000800000-0000000002000000 [ 24.0M] rw-/rwx SM=PRV Application Specific Information: objc[3012]: garbage collection is OFF Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_c.dylib 0x922de341 memmove$VARIANT$sse3x + 1923 1 test1 0x000fc6ff bbMemMove + 31 2 test1 0x00003d5d 149 + 48 3 test1 0x0000361b 109 + 39 4 test1 0x000032fa 75 + 25 5 test1 0x00002afc 4 + 20 6 test1 0x00002d42 -[BlitzMaxAppDelegate applicationDidFinishLaunching:] + 354 7 com.apple.Foundation 0x92cb3df1 __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 49 8 com.apple.CoreFoundation 0x94ae5903 ___CFXNotificationPost_block_invoke_1 + 275 9 com.apple.CoreFoundation 0x94ab0688 _CFXNotificationPost + 2776 10 com.apple.Foundation 0x92c9efde -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 11 com.apple.AppKit 0x980b7d99 -[NSApplication _postDidFinishNotification] + 259 12 com.apple.AppKit 0x980b7a8f -[NSApplication _sendFinishLaunchingNotification] + 84 13 com.apple.AppKit 0x980b65b0 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 277 14 com.apple.AppKit 0x980b62c6 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 377 15 com.apple.CoreFoundation 0x94afe1c8 -[NSObject performSelector:withObject:withObject:] + 72 16 com.apple.Foundation 0x92cd90c2 __-[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke_1 + 121 17 com.apple.Foundation 0x92cd7e75 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 476 18 com.apple.Foundation 0x92cd7c49 _NSAppleEventManagerGenericHandler + 234 19 com.apple.AE 0x999d2045 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 202 20 com.apple.AE 0x999bbb67 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 43 21 com.apple.AE 0x999bba54 aeProcessAppleEvent + 253 22 com.apple.HIToolbox 0x95d4cc66 AEProcessAppleEvent + 103 23 com.apple.AppKit 0x980b3347 _DPSNextEvent + 1301 24 com.apple.AppKit 0x980b2942 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113 25 com.apple.AppKit 0x980aecb1 -[NSApplication run] + 911 26 test1 0x00003150 main + 1024 27 test1 0x00002689 _start + 208 28 test1 0x000025b8 start + 40 Thread 1:: Dispatch queue: com.apple.libdispatch-manager 0 libsystem_kernel.dylib 0x949ce90a kevent + 10 1 libdispatch.dylib 0x9cb8ae10 _dispatch_mgr_invoke + 969 2 libdispatch.dylib 0x9cb8985f _dispatch_mgr_thread + 53 Thread 2: 0 libsystem_kernel.dylib 0x949ce02e __workq_kernreturn + 10 1 libsystem_c.dylib 0x92307ccf _pthread_wqthread + 773 2 libsystem_c.dylib 0x923096fe start_wqthread + 30 Thread 3: 0 libsystem_kernel.dylib 0x949ce02e __workq_kernreturn + 10 1 libsystem_c.dylib 0x92307ccf _pthread_wqthread + 773 2 libsystem_c.dylib 0x923096fe start_wqthread + 30 Thread 4: 0 libsystem_kernel.dylib 0x949ce02e __workq_kernreturn + 10 1 libsystem_c.dylib 0x92307ccf _pthread_wqthread + 773 2 libsystem_c.dylib 0x923096fe start_wqthread + 30 Thread 0 crashed with X86 Thread State (32-bit): eax: 0x01923823 ebx: 0x0000001f ecx: 0x00000038 edx: 0xfeedc7c0 edi: 0x01923860 esi: 0x0192387f ebp: 0xbffff038 esp: 0xbffff02c ss: 0x0000001f efl: 0x00010286 eip: 0x922de341 cs: 0x00000017 ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037 cr2: 0x007fffff Logical CPU: 0 are there any atmel programmer here for test this? Sven |