Shop OBEX P1 Docs P2 Docs Learn Events
BS2Function question — Parallax Forums

BS2Function question

PVJohnPVJohn Posts: 60
edited 2006-08-28 22:50 in Propeller 1
Hi,
I'm trying to convert some of my pbasic code to spin, and I found a "problem"·with SERIN command.
I wasn't able to compile spin code when I tried to use "WAIT"
BS2.SERIN_STR(6,[noparse][[/noparse]WAIT ("OK")],9600,1,8). Is this possible·in spin and how?
I'm trying to communicate with Agilent DVM.

Thanks!·

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-08-27 16:55
    The BS2 Functions have not contained a wait. I've re-written some code, and added a WAIT for a single character. The revised BS2 Functions is attached.

    To wait for "OK", you can do it one of 2 ways, using the SERIN_Wait function:

            BS2.Serin_Wait(5,@myString,"K",9600,1,8)           ' Accept string passing pointer for variable,
                                                                                      wait for character K
            BS2.Debug_Str(@myString)                                 ' display string at pointer
    
    
    
    



    Or, manually wait ing code using SERIN_Str:
       repeat
         repeat while (X <> "O")
          x := BS2.SERIN_Char(31,9600,1,8)
    
         repeat while (X <> "K")
          x := BS2.SERIN_Char(31,9600,1,8)
          
        BS2.SERIN_str(31,@myString,9600,1,8) 
        BS2.Debug_Str(@myString)
    
    
    



    Spin isn't fast enough to totally replicate a true Wait, the above codes will work even if "abcOi am here K get this! is sent". But I have tested sending a file with similar from hyperterminal and 99% of the time it got the data after the K without garbage (I'm still amazed an intepretive language is fast enough to process between bytes in a transmission!).

    I'm teaching with the propeller this semester, and maybe a good class project would be to implement these functions BS2 functions in ASM.

    I'll send the new file to Parallax this week and get it updated on the objects page.

    Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control

    Post Edited (Martin Hebel) : 8/27/2006 5:10:11 PM GMT
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-08-27 17:52
    Started testing out some other functions since SERIN_Str seemed to have issues, and found some glitches in SERIN_DEC.

    Sorry for the repost.

    Version 1.3.2

    -Martin
  • NewzedNewzed Posts: 2,503
    edited 2006-08-27 18:14
    Martin, I'm using the serin_char instead of the serin_str and it's working great.·
    all I did was just added a repeat to the method.

    PUB recData
    · x := 0
    · text.str(string("Received:· "))
    · repeat while byteval<>10
    ··· Byteval := BS2.Serin_Char(1,9600,BS2#NInv,8)
    ··· text.out(Byteval)
    · text.out(13)

    Thanks for the updated post.

    Sid





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • PVJohnPVJohn Posts: 60
    edited 2006-08-28 22:50
    Thanks guys, I'll try it later today.

    PVJohn
Sign In or Register to comment.