World: r4wp
[#Red] Red language group
older newer | first last |
Kaj 2-Jul-2013 [9214] | So the problem is in the only piece of the code you didn't show :-) |
Bo 2-Jul-2013 [9215x2] | I could have pasted the whole program in here, but I thought that might have been excessive! :-) |
Sorry for the false alarm and all the trouble. | |
Kaj 2-Jul-2013 [9217] | Is first-line a literal or does it come from a text file? |
Bo 2-Jul-2013 [9218] | Here's the troubling bit of code: dirs: make-c-string 1024 dirs: read-file "to-process/dirs.txt" eol: make-c-string 1024 eol: find-char dirs #"^/" ;Finds the first end-of-line character line-len: as-integer eol - dirs + 1 ;Add one byte for the end-of-string character first-line: make-c-string line-len copy-string-part dirs first-line as-integer eol - dirs ;reversed first-line/line-len: #"^(00)" Shouldn't 'find-char dirs #"^/" return the first newline byte? |
Kaj 2-Jul-2013 [9219x4] | Yes, you're looking for the LF, so you're including the CR |
On Windows, the C library that executes the read-file converts DOS newlines to Unix LF format. I've had trouble with that before in the binding | |
The C library on Unix just assumes it's a native file, so if there are extra CRs in there, it doesn't touch them | |
It's best to standardise on LF format, even on Windows, with a capable editor | |
Bo 2-Jul-2013 [9223] | The dirs.txt file is being written to the Pi using Rebol on Windows. |
Kaj 2-Jul-2013 [9224x2] | Yes, it uses local Windows convention |
You must do the conversion somewhere in the chain | |
Bo 2-Jul-2013 [9226] | So, I'd have to form the file in Rebol, convert it to binary (in Rebol) and remove the CRs from the binary, then use write/binary to write it out. |
Kaj 2-Jul-2013 [9227x2] | Doesn't REBOL have a refinement to force it? |
The other option is to convert it in Red/System | |
Bo 2-Jul-2013 [9229] | write/with |
Kaj 2-Jul-2013 [9230] | R2 only |
Bo 2-Jul-2013 [9231x2] | I'll just use write/append/binary with #{0A} as the terminator. |
It's working now. Thanks for all your detective work! I don't know how you can find bugs so fast. | |
Kaj 2-Jul-2013 [9233] | I didn't think it was very fast. :-) I had a hunch in the direction of corrupted printing all the time, but didn't think of CR |
Bo 2-Jul-2013 [9234] | What I meant was "fast compared to me." |
Kaj 2-Jul-2013 [9235x3] | :-) |
It still sucks to loose hours to this issue fourty years after it was perpetrated | |
I suppose it would be useful if I made read-file more like REBOL, like it already behaves on Windows. I'll look into that tomorrow | |
Bo 2-Jul-2013 [9238] | You're awesome! |
Kaj 2-Jul-2013 [9239] | Thanks |
Bo 2-Jul-2013 [9240] | For anyone interested, I just published a JPG in the Files section under Misc called MotionDetect.jpg showing real-time motion detection performed by the Raspberry Pi running Red/System. The top two frames are the actual camera video (shot at dusk) and the bottom frame highlights the areas of motion. Thanks in huge part goes to Kaj for helping me finish this first project! |
Kaj 2-Jul-2013 [9241] | Cool to see it displayed like that |
Bo 2-Jul-2013 [9242x2] | What do you mean by "displayed like that"? |
By the way, the bottom image is completely built by Red/System. | |
Kaj 2-Jul-2013 [9244] | Well, displayed at all. :-) So far I had only seen isolated code snippets |
Bo 2-Jul-2013 [9245x2] | Have to protect my intellectual property. :-P |
I really can't thank you enough, Kaj, for all your help! | |
Kaj 2-Jul-2013 [9247] | Yes, but that's not what I mean. It's all very abstract and seems like any other code, but now it comes to life |
Bo 2-Jul-2013 [9248x2] | I love the feeling that I get when I see my software working! Especially something I've been struggling with for days/weeks/months. |
My original prototype written in R2 was started 3-Aug-2012 and finished 9-Sep-2012. It's taken this long to get it running on the Pi natively. | |
Kaj 2-Jul-2013 [9250] | Was that fast enough? |
Bo 2-Jul-2013 [9251] | The development cycle? Or the speed of the software? |
Kaj 2-Jul-2013 [9252] | R2 |
Bo 2-Jul-2013 [9253x3] | R2 couldn't do it nearly fast enough on the Pi. |
However, it was fast enough on a powerful workstation. | |
R2 could even handle several cameras simultaneously on a powerful workstation (maybe 4 cameras at 1.3 megapixels @ 8fps). | |
Kaj 2-Jul-2013 [9256] | Not bad, but not available on ARM |
Bo 2-Jul-2013 [9257] | Right. |
Kaj 2-Jul-2013 [9258] | So can you do without the Broadcom specs now? |
Bo 2-Jul-2013 [9259x2] | I've found a way around it for now, but I've had to make some concessions that I'm not very happy with. My goal is to still get my hands on those Broadcom specs so I can get better performance and flexibility. |
My motion detection executable on the Pi is 30KB. The same executable compiled for Windows is 15KB (50% the size). | |
Kaj 2-Jul-2013 [9261] | Yes, the ARM instruction set is optimised for speed at the expense of size |
Bo 2-Jul-2013 [9262x2] | I've got plenty of room on the Pi, but not a lot of processing power. |
So I'm thankful for that. | |
older newer | first last |