OpenLog Commands and file creation

Simmicht

Senior Member
References...
http://wiki.github.com/nseidle/OpenLog/command-set
http://wiki.github.com/nseidle/OpenLog/datasheet

I have an OpenLog device connected to a Picaxe28X2.
I am using Pins C.1 and C.2 . I have a 2GB uSD card installed.

I am trying to create a file name in the form yyymmdd.txt.
Seems from the data sheet all I need to do is send 3 character 26 (^Z)
It should reply with ‘>’ which indicates OpenLog is ready to receive commands. Then I should send "append yyyymmdd.txt" followed by ^Z to be logging to that file.
I know I have the TX & RX the right way around as it LED on the OpenLog flickers when data is sent to it, I have managed to right data to a default log file and I can see the initial string when it starts, which is "12<".

Command Mode
So far I have not been able to get it to respond to the escape sequence.

CONFIG.txt
Also I have not had any luck with the case sensitive file called CONFIG.txt on the uSD card.
I have created the file CONFIG.txt with 9600,26,3,1 as the contents.
That should start up OpenLog with 9600 baud, 26 as the escape char, required 3 times and the 1 indicates SeqLog mode.

SeqLog appends a file called "SeqLog.txt" at every power up and immediately starts logging.

Has anyone managed to have this work? Or had any luck with using the CONFIG.txt file to control and actions.
 

westaust55

Moderator
I am trying to create a file name in the form yyymmdd.txt.
The append command is to add text to the file once created.

As I understand from a quick glance of the website,

Upon power up, in default ‘NewLog’ mode, OpenLog will output ‘12<’ (note the less than sign) at which time you can start throwing characters at it. Those characters will be recorded to LOG###.txt. Press Ctrl+z three consecutive times will cause OpenLog to exit record mode and drop into command mode. Command mode is signified with a ‘>’ (greater than) sign. You can then enter the following commands:

Are you waiting for the “1”, the “2”, and the “<” characters to be transmitted before you send the three [Ctrl-Z] commands and then wait for the “>” character.

Then create a new file:

new file: Creates a new file (named file ) in the current directory.
• Ex: new test_file.txt


Posting your code would make it far easier for others to see potential problems
 

Simmicht

Senior Member
Lazy Programmer

I was lazy, and the code was spaghetti.
So I have a simple version below which returns

PTR=3
12<
TEST -- - 1
TEST -- - 2
TEST -- - 3
TEST -- - 4
TEST -- - 5

The correct stuff appears in the log file created each time it powers up.

If I comment out the GOTO past the Command setups then .

Code:
#picaxe 28X2
#revision 1
#no_data
#no_table
#terminal 9600

symbol PIN_OPENLOG_RX = C.1 'to OpenLog TX
symbol PIN_OPENLOG_TX = C.2 'to OpenLog RX

'count PIN_OPENLOG_RX,6000, w0
'sertxd("count=",#w0,cr,lf)



setfreq m8

gosub ReadWaitDisplay


high PIN_OPENLOG_TX
pause 500


goto writesometing


'enter command mode
sertxd ("^Z^Z^Z",cr,lf)
serout PIN_OPENLOG_TX, T9600_8, (26,26,26)

gosub ReadWaitDisplay


'create file and append to it
sertxd ("new data.csv",cr,lf)
serout PIN_OPENLOG_TX, T9600_8, ("new data.csv",13,10)

gosub ReadWaitDisplay


'create file and append to it
sertxd ("append data.csv",cr,lf)
serout PIN_OPENLOG_TX, T9600_8, ("append data.csv",13,10)

gosub ReadWaitDisplay




'exit command mode
sertxd ("^Z",cr,lf)
serout PIN_OPENLOG_TX, T9600_8, (26)

gosub ReadWaitDisplay


high PIN_OPENLOG_TX
pause 500

writesometing:
FOR B1 = 1 to 5

    sertxd  ("TEST -- - ",#B1, cr,lf)
    serout PIN_OPENLOG_TX, T9600_8, ("TEST -- - ",#B1, cr,lf)

    pause 4000
next
end



'=====================================================
ReadWaitDisplay:

ptr=0
SERIN [4000,nodata], PIN_OPENLOG_RX, T9600_8 ,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc

nodata:
IF ptr>0 THEN 

    sertxd(cr,lf,"PTR= ",#ptr,cr,lf)
    B1 = ptr - 1
    ptr=0

    FOR B0 = 0 TO B1
        SERTXD(@ptrinc)
    NEXT
ELSE
    sertxd (".")
ENDIF

sertxd(13,10)
RETURN
 

Simmicht

Senior Member
The characters that do come back are almost right

I tried the "disk" command as it should just report one line about the uSD card.
See screen capture from the terminal.

According to the doco, when it enters the command mode, it should respond with a ">" character.
 

Attachments

MartinM57

Moderator
At a quick glance looks like it might a baud rate issue on the comms side between the PICAXE and the card

Can you try an external resonator instead of the internal oscillator, just to make sure all your comms baud rates are spot on?
 

Simmicht

Senior Member
Resonator is installed

I do have a 8MHz resonator installed so i will try that tomorrow, not sure why it receives the "12<" initially, but then will not get the subsequent data.

Any one have any luck with the CONFIG.txt file?
 

Simmicht

Senior Member
Check the firmware version

Another thought, I have just bought these from within Australia, but maybe I am wrong to assume they are both 1.6 version, so I better check that tomorrow. It seems from the doco that 1.5 is not so smart with the CONFIG.txt file.
 
Last edited:

Simmicht

Senior Member
More DUH

Upon reading more manual is see this comment...

'sync: Synchronize, or write the current contents of the buffer to the SD card. This command is useful if you have less than 512 characters in the buffer and want to have them committed to the SD card.'

So it probably only writes out a full block of data at a time....yes?

So when I do a test and write a few bytes then power it down again ... maybe it has not been written to the uSD yet.

To further support this, I left the circuit running over the weekend and guess what?
It logged every minutes and even restart after the power went off a few times.
Created a new file as it should have as well. The log file was about 45kb.

One less mystery ...
 

Simmicht

Senior Member
RTFM

Spotted this gem.
'Power Input voltage on VCC can be 3.3 to 12V. Input voltage on RXI pin must not exceed 6V. Output voltage on TXO pin will not be greater than 3.3V.'

I am running the 28X2 at 5V, so I wonder if that explains some of the serial issues I am having now. If it was not for the LCD requiring 5V I would just run the 28X2 at 3.3V and maybe that would cure a few issues.
 
Last edited:

Simmicht

Senior Member
No wonder I was going mad

'In firmware v1.3 and above, OpenLog has an auto-store feature. If OpenLog is idle for 5 seconds or more, it will auto-save any characters in the buffer. This is very helpful for systems that store a few characters every few seconds. This feature also significantly saves on power'

I could not figure out why sometimes it would save the file and other times it would not ... all depended on how long I waited till I powered it off to check the contents of the SD card....

Sorry if this is turning into more of a blog...;)
 
Last edited:

Simmicht

Senior Member
Update

The OpenLog I bought from within Australia was version 1.1, the latest is 1.61.
After flashing the firmware to 1.61, the CONFIG.txt file is now operating as
described in the manual. :)

I have set the CONFIG.txt to 9600,26,3,1
This creates and appends to the SEQLOG.txt file, so the will do for my logging purposes.

Anyone can import that into Excel to do further calculations or graph the data.
 
Top