Shop OBEX P1 Docs P2 Docs Learn Events
SD Card info? — Parallax Forums

SD Card info?

mosquito56mosquito56 Posts: 387
edited 2008-02-24 17:41 in Propeller 1
·I have searched hi and low for instructions for the fsrw, sdspiqasm and can't seem to find any. There are alot of subroutines I may be able to use and was wondering if anyone knew of some instructions.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· Q. What do you get if you put a trs-80 in a steambath?

······· A. A propchip with an attitude
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet

Technologically challenged individual, Please have pity.

Comments

  • rokickirokicki Posts: 1,000
    edited 2008-02-20 08:06
    Hmm, there's the README.txt and then there's documentation in the files themselves.

    What sort of instructions are you looking for?
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-20 17:53
    About the only instruction I can think of is Readline as opposed to readchar. While not a proplem with readchar I am haveing a problem with readchar.

    ·The only info on card in "123linefeed, charreturn" This shows "123· " When I do (Value :=@chr), I get 123 when chr is defined as byte but this limited the max value to 256. I change @char to word and value goes to 9606 which tells me it's a 5 digit hex number now.

    · I have done extensive reading of hex values into vbbasic from GPS and the prop. I haven't tried csv yet so many possiblilities to work around problems are wide open.

    ·A way to trim variables of leading and trailing spaces would be nice also. Is there an ascii code for "null chr"

    I read the text file and the documentation is very good in the files, I guess my proplem is the jargon for fat. For instance, "what does dirty mean?" I guess I am just spitballing here.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-20 18:14
    You'll need to be much clearer about what you want answered. It helps to say "this is what I'm trying to accomplish", "this is what I actually did", "this is what happened".

    It sounds like your problems have nothing to do with the SD card itself or the SD card routines, but more with problems understanding Spin and basic routines for handling arrays of characters.

    "Value := @chr" just sets "Value" to the address of "chr". To get the character there, you have to do "Value := byte[noparse][[/noparse] @chr ]".

    The ASCII value for "null" is zero.

    Look at the routines in the Extended Full Duplex Serial object from the Object Exchange. It has routines for converting character strings into numbers using decimal and hexadecimal. These routines make good examples of how to do similar things.

    You will need to write your own routines to trim leading and trailing spaces. It's not hard. You simply copy a string character by character and ignore the spaces at the beginning and the end.
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-21 05:37
    file.txt on cd card on prop

    read 3 digits from file "123$0A$0D"

    strip chr line feed and chr newline

    print "123"

    I want to store this value to ho as a setting.

    ho:=@chr, gives·7129 as value of ho in main only if· "byte chr' declared in var

    ho:=long[noparse][[/noparse]@chr]·gives 333231 if·"long chr"

    ho:=long[noparse][[/noparse]@chr] gives 00000 if·"byte chr"·

    I have tried every combination possible all to no avail.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-21 06:05
    Like I said, you're unfortunately just trying stuff in Spin without understanding what it does and your issues have nothing to do with SD cards (other than that's where you're getting your information).

    "ho := @chr" puts the address of "chr" into "ho"

    "ho := long[noparse][[/noparse]@chr]" takes the address of "chr" and fetches a long at that address. The least significant 2 bits of the address are ignored.
    This means that the address actually used is always a multiple of 4 (the next lowest multiple of 4). If you declare "chr" as a LONG, "ho"
    will be set to that value. If you declare "chr" as a BYTE, the value depends on where "chr" falls in the 4 byte LONG fetched.

    You really need to download the Extended Full Duplex Serial object. It has a method (RxDec) that does most of what you need. It gets its characters from the Full Duplex Serial driver, but you can substitute the SD card ReadByte method for the serial RX method to get the data from an SD card file.
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-21 08:09
    ·Got the extended and see what your driving at. It's identical to packing the output byte when trying to print numbers with graphics.spin. Back to packing bytes.



    ·if (dataIn[noparse][[/noparse]x] => ("0")) and (datain[noparse][[/noparse]x] =< ("9"))

    This is what I was trying to do· but I didn't know you had to put the numbers in quotes. Thanx





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-24 05:37
    I am reading a txt file from an Sd Card
    I want to set values from Sd card

    ok, thanx a million, got the program to read a number and compute number, read a character and print type of char: i.e.
    if n print "number"
    if s print "string"
    if d print "date"

    Next is strings,
       case long[noparse][[/noparse]@info]
        "owner":
          printstr(string("ownerxx"))
        "Num":
           printstr(string("Numberxx"))
        
    dat
       info long "owner" 
    
    

    Shouldn't this print ownerxx?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet


    Post Edited (mosquito56) : 2/24/2008 6:11:06 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-24 05:51
    None of the standard operators (like "==" or even ":=") work on strings. The CASE statement uses "==" by default so you can't have strings for CASE labels. In what you've written, you're using an integer as the CASE expression that contains a 4 byte / long value which does contain 4 characters, but you'd have to be careful to use zeros as the unused high order bytes and use only up to 4 characters.

    Take a look at FemtoBasic for an example of a string table lookup, then a CASE statement that uses ordinary (ordinal) integers for the actions that correspond to the words. In FemtoBasic, the keywords get looked up for the entire statement as it's entered and the integers get substituted for the text of the keyword, but you should be able to lift the table search routine mostly unchanged.

    I have used a CASE statement with labels consisting of the first 4 characters of keywords treated as a long. Take a look at the Propeller OS. There's a link in Graham Stabler's Good Thread Index.

    You can use STRCOMP to compare two zero-terminated strings for equality or inequality. You can also use a combination of STRSIZE and BYTEMOVE to do string assignments of zero-terminated strings (without checking for proper destination length) as in "BYTEMOVE(@dest,@src,STRSIZE(@src)+1)" which also copies the terminator.

    Post Edited (Mike Green) : 2/24/2008 5:56:14 AM GMT
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-24 06:10
    Thanx,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • mosquito56mosquito56 Posts: 387
    edited 2008-02-24 17:04
    This is the only thing I could think that may do a "lookup"

    PUB key : keycode

    '' Get key (never waits)
    '' returns key (0 if buffer empty)

    · if par_tail <> par_head
    ··· keycode := par_keys.word[noparse][[/noparse]par_tail]
    ··· par_tail := ++par_tail & $



    I have never seen par_keys.word[noparse][[/noparse]par_tail], the decimal is new. Since there is no object "par_keys"

    long· par_keys[noparse][[/noparse]8]···· 'key buffer (16 words)· read-only······ (also used to pass initial parameters)

    Since I thought a word was equal to 4 longs, "16 words" confuses me.

    Also, I thought read only meant the var couldn't be modified?

    I think this may be a C thing and I don't know C.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-24 17:41
    The decimal notation is described in the Propeller manual in the sections on BYTE / WORD / LONG. In the Propeller, as described in the manual and true for the Stamps as well, a word is a 16 bit value. To avoid confusion with the use of "word" to describe 32-bit words, these are described as "long" or "long word". There's no standard for describing units of storage larger than a byte. It depends on the programming language used and the architecture of the processor involved.

    The comment you're referring to "key buffer (16 words) read-only" indicates that this variable is used as a keystroke buffer or key buffer and, even though it's declared as an array of 8 longs, is used by the routines involved as an array of 16 words. To the Spin code, it's treated as read-only. Only the assembly routine writes into the array. The description has nothing to do with C.

    The reason for declaring this array as longs is that the compiler sorts variables into groups. Within an object's VAR section, all longs are allocated first, then all words, then all bytes. The order of these particular variables is important to the assembly routines, so they're all described as longs so they'll stay together in order.

    This is not a "lookup" routine. If you want to see examples of that, you should download one or both of the programs I suggested and begin to go through them to understand what was done to look up keywords. Pretty much any programming text will discuss dictionary lookup routines in general. They're kind of a staple of programming.
Sign In or Register to comment.