Shop OBEX P1 Docs P2 Docs Learn Events
serial obj for SPIN+P2+PropTool v2.2 — Parallax Forums

serial obj for SPIN+P2+PropTool v2.2

Can anyone point me to a serial object that works under Propeller Tool for the P2?
I see various incarnations around but they don't seem to target this specific environment:

h/w = P2 ES Eval Board RevB
IDE = Propeller Tool v2.2.0.0 alpha
to be called from SPIN

any help appreciated,

cheers,
Mark

Comments

  • You can use JonnyMac's jm_serial object in the P2 Object Exchange... Find that via git at: https://github.com/parallaxinc/propeller Once you have git cloned the complete repository (it's not to big), look in: propeller/libraries/community/p2/ALL/jm_serial for the .spin2 library code. In Propeller Tool v2.3.0.0 alpha, you can use the following code as an example.
    {testPT.spin2 test jm_serial with Propeller Tool}
    CON
      mode = $010007f8
      freq = 160_000_000
      baud = 230_400
      rx_pin = 63
      tx_pin = 62
      
    VAR
       
    OBJ
      ser: "jm_serial" 
      
    PUB hello()
      clkset(mode, freq)   
    
      ser.start(baud)
      repeat
        ser.str(string("Hello, world!\n"))
    

    dgately
  • If you download manually, be sure to pick up jm_nstr.spin as well -- this handles numeric formatting.
  • JonnyMac wrote: »
    If you download manually, be sure to pick up jm_nstr.spin as well -- this handles numeric formatting.
    That's why I recommend the complete repository :-)

  • Cluso99Cluso99 Posts: 18,069
    How do I just get the three files from git???

    When I click on the filenames it just opens up a new page with the source code listed.

    I just want a download button.
  • dgatelydgately Posts: 1,621
    edited 2020-07-28 04:53
    Cluso99 wrote: »
    How do I just get the three files from git???

    When I click on the filenames it just opens up a new page with the source code listed.

    I just want a download button.
    I'm not going to defend git as I understand that the current obex solution is not "for everyone"... Of course, you can just select the text of a file from github's website (yeah, not what you wanted to hear) and copy & paste.

    At this time, something like GitHub Desktop makes things marginally better. You let the app clone the whole repository to your local drive, and it gives you a UI that allows browsing for files (well, it can use Visual Studio Code to do that). It handles the update process by checking-in on github and letting you know that there have been updates, etc...

    Git (& GitHub) are really designed for entire project-based file access for us "mere mortals" but an expert could create an interface that allows access to single files.

  • Thanks for that - I'm not quite getting the result expected using the code examples above, but if I reduce the Baud rate in my terminal to 38400 it works as expected ... that's out by a factor of 6 compared to the Baud configuration in the code ... I've not delved into how the mode and freq constants operate but it looks like that's where my problem lies.

    cheers,
    Mark
  • Cluso99 wrote: »
    How do I just get the three files from git???

    When I click on the filenames it just opens up a new page with the source code listed.

    I just want a download button.

    Cluso, To get the repo from GitHub without needing git you can click the green Code button and choose download ZIP. This will send you the zip with all the files in it. You get the whole repo folder structure though, not just a few files of interest and I can see this will become a problem when the total repo size gets really large. Otherwise it needs some browsing and cut/paste source for individual text files which I admit could be tedious and also not be any good for binary files.
  • Cluso99Cluso99 Posts: 18,069
    rogloh wrote: »
    Cluso99 wrote: »
    How do I just get the three files from git???

    When I click on the filenames it just opens up a new page with the source code listed.

    I just want a download button.

    Cluso, To get the repo from GitHub without needing git you can click the green Code button and choose download ZIP. This will send you the zip with all the files in it. You get the whole repo folder structure though, not just a few files of interest and I can see this will become a problem when the total repo size gets really large. Otherwise it needs some browsing and cut/paste source for individual text files which I admit could be tedious and also not be any good for binary files.
    That's the problem. I only want the subset in the one subdirectory. I, and I bet others, will not want to download hundreds of files just to get 3 :(
    In its' current form, it's a disaster and definately not a replacement for OBEX.

    A few specific problems for me
    * I use the cellular network (no landline of any sort)
    * Therefore I have a download limit too
    * Downloads to my SSD so I want to limit what is written
  • Cluso, there may be an option in your browser to "download linked file and save as" when you select the file in the folder listing. For binary files I see there is a Download button in github. I was just able to get a pdf from the repo this way, so it may still be possible to cherry pick only what you want.
  • Cluso99Cluso99 Posts: 18,069
    rogloh wrote: »
    Cluso, there may be an option in your browser to "download linked file and save as" when you select the file in the folder listing. For binary files I see there is a Download button in github. I was just able to get a pdf from the repo this way, so it may still be possible to cherry pick only what you want.
    I did try but all I received to the file listing. No download option and no automatic download.
  • roglohrogloh Posts: 5,158
    edited 2020-07-28 08:25
    For recognized files being viewed in github right click the button that says "Raw" and see what you can do in your browser - it may let you save the file from this link (Safari allows this). For binary files I got a Download button option appearing when I view the file, and can then save from there. Some of this may be browser dependent.
  • No download option...
    I did find a download button associated with ZIP files, but not others.
  • I only see the download button when attempting to view binary files, e.g. pdf or gif. Most repo files are text so you won't see it with those and need to cut/paste and/or click the Raw button.
  • Cluso99Cluso99 Posts: 18,069
    Just spent more time on trying to download the 3 files, or any one of them.
    Nothing on those pages has anything related to downloading as far as I can see.
    There is no RAW section/button on my screen.

    I am using W10 Pro and Chrome x64 v84 (latest).

    I am not interested in copy/paste, nor downloading the whole git repository. So git in its' current form is useless. No point in wasting anymore time here.

    IMHO currently it's better to post a thread with code on the forum. At least it's accessible for everyone there.
  • Here's what I see in Safari with GitHub if I right click the "Raw" button where I can then download the file and save it.

    If the file is non-text I get a different screen that has the Download button instead. Examples attached below. Maybe other browsers will present the GitHub site differently, or you may need to turn on JavaScript etc. I don't know.
    1159 x 629 - 123K
    1155 x 418 - 64K
  • Cluso99Cluso99 Posts: 18,069
    edited 2020-07-29 03:07
    @rogloh,
    Thanks. I now see the raw when I get to the individual file. But clicking this just gives a listing of the source.

    When downloading a zip file (like Eric's flexgui) and unzip I get the date the file was created/updated. This is essential for ensuring you have the latest files. Copying/pasting would lose that info, and any other info about the file.

    I fail to see any benefit in git whatsoever, just obstacles.
    960 x 540 - 97K
    960 x 539 - 111K
    964 x 543 - 86K
  • Cluso99Cluso99 Posts: 18,069
    Singing the praises of JonnyMac's Serial driver :smiley:

    Unfortunately I couldn't find Jon's thread :(

    While debugging my P2 OS I came upon this type of code I used with Kye's string handling (ASCII0 String Engine) spin1 code
        Print.Str(string(" Serial  on pins "))
        Print.Str(1 + str.integerToDecimal(z1, 2))
        Print.Char(",")
        Print.Str(1 + str.integerToDecimal(z0, 2))
        Print.Str(string(", Mode "))
        Print.Str(1 + str.integerToDecimal(z2, 2))
        Print.Str(string(", Baud "))
        Print.Str(1 + str.integerToDecimal(z4, 8))
        Print.Str(string(", Cog "))
        Print.Str(1 + str.integerToDecimal(z3, 1))
        Print.CRLF()
    
    Using JonnyMac's serial this can be simplified into the one line below (yes, I could make the above into 1 line but it wouldn't be readable)
        Print.fstr5(string(" Serial  on pins %2d,%2d, Mode %2d, Baud %8d, Cog %1d\r\n"), z1, z0, z2, z4, z3)
    
Sign In or Register to comment.