To get rid of the time stamp mismatch problem just go into the close file function and comment out the "readWriteSector("W")" functions. Don't comment out the ones with "R" only the ones with "W". This will get rid of that problem.
Even better. Just go to the last PRI function called readWriteBlock and change it to this.
I just commented all the write functions I will not used and I saved only 6 longs So probably I will just de-activate the write feature they way you are pointing above, and keep the original file...
Is there any write variable/buffer I can remove too? Or is the compiler removing it automatically if it's not used anymore?
Don't put that stuff into the if statement. That will cause stuff not to work at all.
If you're looking to save space just comment out all the public functions that you don't plan to use that don't cause compilier errors when commented out.
If I know the path of "something" and I want to know if it's a file or a directory. Is there something like getType(path)?
There is listIsDirectory, but is it working only when you call listName first?
Thanks,
JM
UPDATE: RTFM... So I have my respons. Thanks.
'' ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
'' │ Returns whether or not the current file or directory pointed to by "listName" is a directory. │
'' │ │
'' │ If a file is currently open this function will retrieve that file's information. │
'' │ │
'' │ If "listName" did not succed or was not previously called the value returned is invalid. │
'' │ │
'' │ Returns true or false. │
'' └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Thanks for making this driver available. I am working on a telemetry project that logs data to an SD card. While logging about 200 byte data every 100ms, I want to play back wav files from the same SD card every few seconds. Would the driver able to do this of having two files open? or do I need to close the data file and store them in a buffer while playing back the wave file? What is the best way to go about this?
Where can I find the latest copy of KyeDOS? I tried downloading DR Acula's versions from a few pages back, but the zip files kept asking for password to unzip them. TNX .. cheers BBR.
When I read from the beginning to the end, it always return 128 bytes per read using this code except the last call.
index := fs.readData (@sd_buffer, c#sdBufferSize)
sdBufferSize = 128.
If I read until index != 128, I read more than the file size. I don't know why, but readData is returning more than the file. So I read the file based on listSize like you did on the demo and it's working fine.
Seems that the value returned by readData is not always correct and is sometime trying to get more than what is available.
File size is 3511, but I can read 28 times 128 and 54. Total is 3638. Everything is "0" after the real end of the file. There is 127 extra bytes.
Same kind of results with a 512 bytes buffer, but this time I have 7x512+68=3652 instead of 3511.
Second "issue", maybe related...
Reading the same file, if I move in the middle before reading it, I get strange readData results.
When I do a fs.changeFilePosition (840), and then read 3 chunks, I get 128, 72, 128. The 2nd chunk is not complet. When I display it on the screen, it's really missing pieces
I'm using version 1.3. I did one modification to have it read-only but removed my update and restored the original file, with no result.
Do you have any updated version I can try? Any clue why it's doing that?
jmspaggi -Read data is not made to return the number of valid bytes read. It just happens to do so since I used the result variable for computation purposes. If you look at the documentation you will notice that I do not say it returns anything.
Please use the "listFileSize" function once the file is open to get the size of the file and then use that to figure how to read bytes from the file.
...
As for not returning data in proper chunk sizes... I don't quite understand what you mean. The FS code should work since it passes the read file backwards test in my demo.
This could be an error however, please give me the code you used and the output and I will add it to my list of things to fix. In the mean time please to to work arround this error.
I've been in the process of updating the code to make it better and much faster. I don't know when I will be done but I will be able to address the problem while changing my code.
I read the comments on your file. Pretty all of them. And I was sure it was returning the quantity! I remember well the error message pointer, and thought it was the size when it's working!
And this is the source of all the issues I saw today.
Because I saw 128 then 57 then 128, I read only 57 bytes on the 2nd paquet. Then I jumped to the 3rd, and lost all what was between the 2...
So I remove all my references to the readData returned value, and now everything is working fine!
2nd time I did not read the manual correctly I have to apologize...
This may be a lame question but I am going to ask it anyway!.. A good teacher is not one that simply states facts about a subject but rather makes the student use his imagination and THAT causes learning..
Having said that Teacher, could you prime my imagination and plant some ideas for the SD card file system for me? It looks to me as though the main attraction of the SD and FAT system are more useful for taking data FROM the Prop and storing it on the SD for later use by a PC. Is this mostly correct?
What about getting "something" FROM the SD card for use BY the Prop? What sort of things would the FAT system be used for? Obviously you can't load and execute a program from the SD. What about creating a .JPEG on the PC and some how displaying it on my 7" LCD color monitor? Possible? My display has two video inputs that I can select with a slick little remote. One is connected to the Propeller Backpack and works fine for text. The display is for my R/C submarine project and I would love to be able to display at least pictures when not using the control function.
On Kye's object, there is a method to load a program in the EEPROM and start it. (Look at bootPartition(fileName) details)
That way, you can have like an unlimited memory as long as you are able to split your application in multiple parts.
I'm using the FAT object to only read files from the SD. I don't write anything on it and disable the write methods.
My application is a OGG reader for my car. I stored about 20GO of music files on my SD (All my CDs I ripped), and build a application to navigate through them and play them.
I will also probably store my application menu in a file to safe some memory on the prop.
If I'm able to complete everything, I will add playlist management, an FM receiver, and all what I can found I will also probably add few EEPROMs images on the SD with some games (nibbles, etc.) just for fun.
Obviously you can't load and execute a program from the SD.
Sure you can. The Zog byte code interpreter loads it's runnable program binaries from SD card all the time. It can also load "blobs" of compiled PASM code from SD into COG and start them running there.
The ZiCog and jaZ80 Z80 emulators load entire CP/M operating systems from SD card and run them which in turn load their executable Z80 binaries from CP/M files on th SD.
I'm sure there are BASIC and other systems for the Prop that load executable code from SD.
heater is right - it is easy to load and run programs off an sd card. qZ80 can do it for C/Basic/Fortran/Forth etc.
But - qZ80 can't do jpeg picture graphics, as the emulation fills up the propeller memory so there isn't enough room for hi-res graphics (Though it is good enough for '80s games). http://smarthome.viviti.com/propeller are some of the programs you can load and run off an sd card.
Also - there is KyeDOS - which gives you a menu of propeller eeprom images, and you can select the one you want and it loads it. So you can boot into KyeDOS, then select which emulation you want to run (complete with its own custom disk image format) then run that emulation and it then loads the correct disk image off the sd card and then runs individual programs off the disk.
KyeDOS also can do other clever things - eg you can load up a disk image, say, PropBasic, run a program, write some data back to the sd card, write a .ini file as well, reboot the card from software control, it then runs the program in the .ini file (eg a Catalina C program) which can pass control etc. The only catch is that there is a bit of a delay (a few seconds) between each reload of 32k of data from the sd card into the propeller - though I think Kye might have sped this up a bit recently.
So it could be possible to have a very simple propeller program that displays a background jpeg on a screen, and a button or keypress or something that selects a program to run.
I don't think all the possibilities have been explored yet. What we have now is a simple text menu of programs you can run on an sd card, but there probably is no reason that menu could not be overlaid on a jpeg picture.
Wow, thanks for all the great insight into the SD card and FAT system. The mind reals!! lol..
Dr Acula, what a wild man!! I cut my teeth on CP/M and MP/M. I was in partnership with a gent back in the day and started with the IMSAI 8080 which I had serial number 000013! Eventually the 8080 computer was fully populated with 64K (8 boards) and made a DANDY room heater!
We built a 6 user MP/M system for a company in California that they used for years doing their invoices, inventory control, payroll etc. At one time it was the largest MP/M installation outside of Digital Reasearch itself. We built the whole system in solid Oak wood, 6 individual computers and a single server computer. We paid at the time $3300.00 for a 40 MEGABYTE (not gig) 8" hard drive and it was just fine for the system.
We ran a really great data base manager called "ODBS, Ohanlon Data Base Soultions" (I STILL have a copy of that system on a 5" floppy! lol). The whole system was parked in a room with a CNC wire cutting machine and was air conditioned MOST of the time. That last sentenance was the key to it's demise!. The system ran 24/7 and the A/C happened to die one weekend and it got to well over 100 degrees in the room and alas the boot floopy and all the backups died and the system was never to be reborn.
Or yZ80 will run M/PM on Prop on a DracBlade board.
This all started for me years ago when I wanted to emulate an Intel 8080 on a Prop, just as a way to learn Prop assembler. That was the PropAltair project with the aim of making an Altair computer form a Prop. http://forums.parallax.com/showthread.php?t=101495
I decreased booting time down to 2 seconds now in the new version I am working on. But, school has started so the release date may be in December after the semester is over.
@w4fej - I don't think I can give you ideas on what to do with the code. I can only just enable you to use an SD card freely.
Kyedos attached. It is Kye's code with a some changes so it creates a boot menu. Stripped out a bit of code and replaced it with a VT100 driver. It might need some minor tweaks to run on the propeller demo board. The core of the program is this
PrintStringCR(string("**** SD card operating system by Kwabena W. Agyeman ****"))
PrintString(string("Type Help for command listing"))
crlf
DisplayBinaryFiles ' display all files ending in .BIN
'fat.bootpartition(string("CPM.BIN")) ' uncomment this to autorun a binary spin file
sio.rxflush(0) ' in case try to send an xmodem transfer
@w4fej, are you interested in running MP/M on the propeller? I have this working with 8 users but I'm having a few problems with random crashes after running for 20 minutes with lots of hard drive activity, so something isn't quite stable. http://smarthome.viviti.com/mp-m I'd appreciate some input from an expert! Swap hardware for your expertise??
"Now, what about scraping that Ohanlon Data Base Soultions software off of the floppy disk so that the Propeller can have a database "
You interested in that?? I miss spoke, it's on a 3" floppy, not a 5". It's small enough I could probably email the whole development system to you. Let me see if I can lay my hands on it..
I'm also trying to build a changePath method which accept "/repA/repB/repC" as parameter, but it's not workign too First draft here. Will still work on that a bit.
PUB changePath(path) | i
changeDirectory("/")
result := 1
i := 1
repeat until result == strsize(path)
if (byte[@path+result] == "/") or (byte[@path+result] == "\")
bytemove (@changePathNameBuffer, @path+i, result-i)
byte[@changePathNameBuffer+result-i] := 0
changeDirectory(changePathNameBuffer)
i := result+1
result++
Yeah, the pop and push method won't do what you want. The string I use has nothing to do with where you are on the file system.
What you want to backup are the (currentDirectory, currentCluster, currentSector, and currentByte) variables. They control where you are in the directory.
Mainly just backup the currentDirectory variable. Then when you want to go back into the directory you backed up assign to the current directory the backed up variable and then call listReset.
...
You should just wait until I get pathing working before trying to use pathing like features. However, I will not be able to tackle that anytime soon.
Otherwise, you can impltment pathing your self by evaluating the path through CDing until you are in the proper folder.
Here is the code if you want to integrate it in your next version. I also did changePath. It's working fine for me. So should be correct. I'm quite sure it can be optimized, but I'm new in Spin, so it's already a big success for me
JM
PUB pushd
currentDirectoryBackup := currentDirectory
return listWorkingDirectory
PUB popd
currentDirectory := currentDirectoryBackup
listReset
return listWorkingDirectory
PUB changePath(path) | i, j
result := 0
if byte[path] == "/" or byte[path] == "\"
result := 1
i := result
changeDirectory(string("/"))
repeat until result == strsize(path)
if ((byte[path+result] == "/") or (byte[path+result] == "\"))
bytemove (@changePathNameBuffer, path+i, result-i)
byte[@changePathNameBuffer+result-i] := 0
changeDirectory(@changePathNameBuffer)
i := result+1
result++
return listWorkingDirectory
I seem to have a problem. In the code listed below it works well the first time but when I reset my Propeller I never get to text.str(string("SD Mounted")). It will work on reset if I have ejected the SD Card and reinserted it. The hardware I'm using is Spin Studio with the Game Stacker and a generic 64 MB SD Card. Thanks.
Comments
Even better. Just go to the last PRI function called readWriteBlock and change it to this.
Basically just put the
cardCommandFlag := command
repeat while(cardCommandFlag)
lines inside of an in statement. The if statement being " if(command <> "W") "
This will basically turn off writing everywhere.
Should I also put
Into the same if statement?
I just commented all the write functions I will not used and I saved only 6 longs So probably I will just de-activate the write feature they way you are pointing above, and keep the original file...
Is there any write variable/buffer I can remove too? Or is the compiler removing it automatically if it's not used anymore?
Thanks,
JM
If you're looking to save space just comment out all the public functions that you don't plan to use that don't cause compilier errors when commented out.
So I removed that from the statement, and still working too.
I will now try to play with it and see if I'm able to do what I'm trying to do.
Thanks,
JM
One more question.
If I know the path of "something" and I want to know if it's a file or a directory. Is there something like getType(path)?
There is listIsDirectory, but is it working only when you call listName first?
Thanks,
JM
UPDATE: RTFM... So I have my respons. Thanks.
I'm quite interested in your file system for the SD cards however the attachment appears to be corrupted. (Never mind, I found the file in the Obex.)
What hardware do you recommend for this??
An amazing piece of work..
Mike B.
Just buy an SD card adapter from parallax and you'll be ready to go.
Thanks for making this driver available. I am working on a telemetry project that logs data to an SD card. While logging about 200 byte data every 100ms, I want to play back wav files from the same SD card every few seconds. Would the driver able to do this of having two files open? or do I need to close the data file and store them in a buffer while playing back the wave file? What is the best way to go about this?
Thanks
Istvan
As in
Then put locks arround every call to the driver. Each copy can have one file open.
I found something strange on the SD driver.
First "issue"...
I'm reading a file by 128 byte chunks.
When I read from the beginning to the end, it always return 128 bytes per read using this code except the last call.
sdBufferSize = 128.
If I read until index != 128, I read more than the file size. I don't know why, but readData is returning more than the file. So I read the file based on listSize like you did on the demo and it's working fine.
Seems that the value returned by readData is not always correct and is sometime trying to get more than what is available.
File size is 3511, but I can read 28 times 128 and 54. Total is 3638. Everything is "0" after the real end of the file. There is 127 extra bytes.
Same kind of results with a 512 bytes buffer, but this time I have 7x512+68=3652 instead of 3511.
Second "issue", maybe related...
Reading the same file, if I move in the middle before reading it, I get strange readData results.
When I do a fs.changeFilePosition (840), and then read 3 chunks, I get 128, 72, 128. The 2nd chunk is not complet. When I display it on the screen, it's really missing pieces
I'm using version 1.3. I did one modification to have it read-only but removed my update and restored the original file, with no result.
Do you have any updated version I can try? Any clue why it's doing that?
Thanks,
JM
Please use the "listFileSize" function once the file is open to get the size of the file and then use that to figure how to read bytes from the file.
...
As for not returning data in proper chunk sizes... I don't quite understand what you mean. The FS code should work since it passes the read file backwards test in my demo.
This could be an error however, please give me the code you used and the output and I will add it to my list of things to fix. In the mean time please to to work arround this error.
I've been in the process of updating the code to make it better and much faster. I don't know when I will be done but I will be able to address the problem while changing my code.
Thanks,
I read the comments on your file. Pretty all of them. And I was sure it was returning the quantity! I remember well the error message pointer, and thought it was the size when it's working!
And this is the source of all the issues I saw today.
Because I saw 128 then 57 then 128, I read only 57 bytes on the 2nd paquet. Then I jumped to the 3rd, and lost all what was between the 2...
So I remove all my references to the readData returned value, and now everything is working fine!
2nd time I did not read the manual correctly I have to apologize...
Thanks for you prompt feedback!
JM
This may be a lame question but I am going to ask it anyway!.. A good teacher is not one that simply states facts about a subject but rather makes the student use his imagination and THAT causes learning..
Having said that Teacher, could you prime my imagination and plant some ideas for the SD card file system for me? It looks to me as though the main attraction of the SD and FAT system are more useful for taking data FROM the Prop and storing it on the SD for later use by a PC. Is this mostly correct?
What about getting "something" FROM the SD card for use BY the Prop? What sort of things would the FAT system be used for? Obviously you can't load and execute a program from the SD. What about creating a .JPEG on the PC and some how displaying it on my 7" LCD color monitor? Possible? My display has two video inputs that I can select with a slick little remote. One is connected to the Propeller Backpack and works fine for text. The display is for my R/C submarine project and I would love to be able to display at least pictures when not using the control function.
Well teacher, fire up my imagination!! :idea:
Mike B.
On Kye's object, there is a method to load a program in the EEPROM and start it. (Look at bootPartition(fileName) details)
That way, you can have like an unlimited memory as long as you are able to split your application in multiple parts.
I'm using the FAT object to only read files from the SD. I don't write anything on it and disable the write methods.
My application is a OGG reader for my car. I stored about 20GO of music files on my SD (All my CDs I ripped), and build a application to navigate through them and play them.
I will also probably store my application menu in a file to safe some memory on the prop.
If I'm able to complete everything, I will add playlist management, an FM receiver, and all what I can found I will also probably add few EEPROMs images on the SD with some games (nibbles, etc.) just for fun.
JM
Can you add that to your driver?
' Store current directory on the top of heap
PUB pushD
' Go pack to the first directory on the heap
PUB pop
Or maybe without any heap, like store it, restore it.
Also, is there a way to know if we are at the root? And we have to count how many directory we opened to know how many ".." we can do?
Just some ideas
Thanks,
JM
Sure you can. The Zog byte code interpreter loads it's runnable program binaries from SD card all the time. It can also load "blobs" of compiled PASM code from SD into COG and start them running there.
The ZiCog and jaZ80 Z80 emulators load entire CP/M operating systems from SD card and run them which in turn load their executable Z80 binaries from CP/M files on th SD.
I'm sure there are BASIC and other systems for the Prop that load executable code from SD.
But - qZ80 can't do jpeg picture graphics, as the emulation fills up the propeller memory so there isn't enough room for hi-res graphics (Though it is good enough for '80s games). http://smarthome.viviti.com/propeller are some of the programs you can load and run off an sd card.
Also - there is KyeDOS - which gives you a menu of propeller eeprom images, and you can select the one you want and it loads it. So you can boot into KyeDOS, then select which emulation you want to run (complete with its own custom disk image format) then run that emulation and it then loads the correct disk image off the sd card and then runs individual programs off the disk.
KyeDOS also can do other clever things - eg you can load up a disk image, say, PropBasic, run a program, write some data back to the sd card, write a .ini file as well, reboot the card from software control, it then runs the program in the .ini file (eg a Catalina C program) which can pass control etc. The only catch is that there is a bit of a delay (a few seconds) between each reload of 32k of data from the sd card into the propeller - though I think Kye might have sped this up a bit recently.
So it could be possible to have a very simple propeller program that displays a background jpeg on a screen, and a button or keypress or something that selects a program to run.
I don't think all the possibilities have been explored yet. What we have now is a simple text menu of programs you can run on an sd card, but there probably is no reason that menu could not be overlaid on a jpeg picture.
Dr Acula, what a wild man!! I cut my teeth on CP/M and MP/M. I was in partnership with a gent back in the day and started with the IMSAI 8080 which I had serial number 000013! Eventually the 8080 computer was fully populated with 64K (8 boards) and made a DANDY room heater!
We built a 6 user MP/M system for a company in California that they used for years doing their invoices, inventory control, payroll etc. At one time it was the largest MP/M installation outside of Digital Reasearch itself. We built the whole system in solid Oak wood, 6 individual computers and a single server computer. We paid at the time $3300.00 for a 40 MEGABYTE (not gig) 8" hard drive and it was just fine for the system.
We ran a really great data base manager called "ODBS, Ohanlon Data Base Soultions" (I STILL have a copy of that system on a 5" floppy! lol). The whole system was parked in a room with a CNC wire cutting machine and was air conditioned MOST of the time. That last sentenance was the key to it's demise!. The system ran 24/7 and the A/C happened to die one weekend and it got to well over 100 degrees in the room and alas the boot floopy and all the backups died and the system was never to be reborn.
Ah yes, those were the "good" ole days.
Mike B.
Great story re: CP/M and MP/M.
And now you can run all your favorite CP/M programs on the Prop under ZiCog or yZ80 emulators and put it all in a matchbox:
http://hackaday.com/2009/12/27/zilog-in-a-matchbox/
Or yZ80 will run M/PM on Prop on a DracBlade board.
This all started for me years ago when I wanted to emulate an Intel 8080 on a Prop, just as a way to learn Prop assembler. That was the PropAltair project with the aim of making an Altair computer form a Prop. http://forums.parallax.com/showthread.php?t=101495
That grew into a full blown Zilog Z80 emulation with the ZiCog project, which ended up in the matchbox. http://forums.parallax.com/showthread.php?t=110804
Since then PullMoll has pushed things along even further with his qZ80 emulator for the Prop which now runs MP/M http://forums.parallax.com/showthread.php?t=121579
Now, what about scraping that Ohanlon Data Base Soultions software off of the floppy disk so that the Propeller can have a database
@w4fej - I don't think I can give you ideas on what to do with the code. I can only just enable you to use an SD card freely.
@w4fej, are you interested in running MP/M on the propeller? I have this working with 8 users but I'm having a few problems with random crashes after running for 20 minutes with lots of hard drive activity, so something isn't quite stable. http://smarthome.viviti.com/mp-m I'd appreciate some input from an expert! Swap hardware for your expertise??
You interested in that?? I miss spoke, it's on a 3" floppy, not a 5". It's small enough I could probably email the whole development system to you. Let me see if I can lay my hands on it..
Mike B.
I tried to implement pushd and popd, but it's not working. pushd seems to be working fine, but popd send me back to the root.
Might be missing something on popd. Any idea?
I'm also trying to build a changePath method which accept "/repA/repB/repC" as parameter, but it's not workign too First draft here. Will still work on that a bit.
JM
What you want to backup are the (currentDirectory, currentCluster, currentSector, and currentByte) variables. They control where you are in the directory.
Mainly just backup the currentDirectory variable. Then when you want to go back into the directory you backed up assign to the current directory the backed up variable and then call listReset.
...
You should just wait until I get pathing working before trying to use pathing like features. However, I will not be able to tackle that anytime soon.
Otherwise, you can impltment pathing your self by evaluating the path through CDing until you are in the proper folder.
It's working A1!
Thanks a lot!
Here is the code if you want to integrate it in your next version. I also did changePath. It's working fine for me. So should be correct. I'm quite sure it can be optimized, but I'm new in Spin, so it's already a big success for me
JM