We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Recording serial stream
Page Index Toggle Pages: 1
Recording serial stream (Read 1059 times)
Recording serial stream
Nov 23rd, 2009, 12:30am
 
Hi,
I do want to record the serial stream coming from arduino to a file. I found "saveStream(targetFilename, sourceLocation)
" describtion in the Reference, but it doesn't work.

I opened a empty file in C:\ and named it test.txt

The code I used was:
Code:
saveStream(test.txt, c:\) 



I tried several other syntax but couldn't get it running. What did I do wrong?
Re: Recording serial stream
Reply #1 - Nov 23rd, 2009, 4:24am
 
These parameters are strings. You have to put them between double quotes:
saveStream("test.txt", "c:\\")
Notice also the doubled backslash. You could have written also "C:/".
Re: Recording serial stream
Reply #2 - Nov 23rd, 2009, 7:23am
 
Ahhh- now somthing is happening.

Unfortunately is creates an empty file everytime the line of code is executed. The file names are something like

Code:
test.txt2177642737759354087.tmp
test.txt926895826807246688.tmp
test.txt4216974103557002931.tmp
test.txt7871416774013919003.tmp
test.txt789356447962487591.tmp
test.txt8426553106928063825.tmp
test.txt4183177127317637710.tmp
test.txt5447273698457453285.tmp


This is not what should happen Embarrassed
Re: Recording serial stream
Reply #3 - Nov 23rd, 2009, 9:14am
 
Actually, I was always perplexed by this function, failing to understand its usage... The terse explanation in the reference page doesn't help much...

So I searched this function name (with top search box), and the first forum link (saveStream troubles) was enlightening: apparently, its canonical usage is to save on disk a file fetched from the network (eg. Internet).

The reference page says: "Save the contents of a stream to a file in the sketch folder. This is basically saveBytes(blah, loadBytes()) [...]" and "saveStream(targetFilename, sourceLocation)
targetFilename        String: name of the file to write to
sourceLocation      String: location to save the file
"

I think it should state: "Save the contents of a stream loaded from given location to a file in the sketch folder. This is basically saveBytes(targetFilename, loadBytes(sourceLocation)) [...]" and "saveStream(targetFilename, sourceLocation)
targetFilename        String: name of the file to write to
sourceLocation      String: location to get the data from
"

I will report this thread in the documentation fix suggestions forum. [Done: saveStream confusing description]

In short, I don't think this function is what you need...
Page Index Toggle Pages: 1