Shop OBEX P1 Docs P2 Docs Learn Events
Is there a way to send these 2 commands together? — Parallax Forums

Is there a way to send these 2 commands together?

Don MDon M Posts: 1,653
edited 2011-08-18 08:34 in Propeller 1
I have these 2 lines:
txmdbinv($1_08, MDB_MSTR)
txmdbinv($0_08, MDB_MSTR)

Can they be combined somehow in one line to send both the $1_08 & $0_08 together? What is the syntax to do so?

Thanks.
Don

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 11:46
    I think we need a little more context here. First of all, where does txmdbinv live, and what does it do? Second, $1_08 is not a byte value.

    -Phil
  • Don MDon M Posts: 1,653
    edited 2011-08-17 11:55
    Phil- Please excuse my ignorance here but I guess I don't know how to ask this properly.

    txmdbinv lives in the initial cog I believe. It is a pub method in my main object. In another program I have I am able to send these 2 "commands" I'll call them, with this line of code:
    txmdb(($1_00) | MDB_ACK,MDB_SLAV) 
    

    MDB_ACK = $00. MDB_SLAV is a pin.

    I tried to do this in my code but it doesn't work: txmdbinv(($1_08) | $08, MDB_MSTR)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 12:13
    The "|" operator is a bitwise OR. It doesn't produce two different parameters, just one: in your case $1_08. If you want your routine to accept more than one command at a time, it needs to be set up to accept the address of a word array, and you need a way to tell it how many active commands are in the array. This can be done either by a unique terminator or by a separate parameter that gives the command count.

    -Phil
  • Don MDon M Posts: 1,653
    edited 2011-08-17 12:16
    So here's what I am trying to explain.

    With this code:
      txmdbinv($1_08, MDB_MSTR)
      txmdbinv($0_08, MDB_MSTR)
    

    I get this as an output:

    08 command.jpg


    Is there a way to combine both of those lines of code into 1?
    1024 x 175 - 30K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 12:22
    Short answer: no. Not without modifying txdbinv as I explained above.

    -Phil
  • Don MDon M Posts: 1,653
    edited 2011-08-17 12:23
    Phil- Thanks.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-17 13:31
    without knowing more details I can't help

    Questions:

    how many propeller-IO-pins do you use to transfer the commands?

    What kind of interface is this SPI?, Serial?, I2C? something else?

    please attach your complete code to a posting.

    best regards

    Stefan
  • Don MDon M Posts: 1,653
    edited 2011-08-17 15:36
    I didn't realize this would be as difficult as it seems to be. My ignorance here...

    It involves only 1 IO pin and it is serial. It isn't that important that it be condensed. I was just curious as I had seen it work in another program I have with similar conditions.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-17 23:00
    I didn't realize this would be as difficult as it seems to be. My ignorance here...

    It involves only 1 IO pin and it is serial. It isn't that important that it be condensed. I was just curious as I had seen it work in another program I have with similar conditions.

    So what does this mean? Do you stop working on this?
    keep the questions coming
    best regards

    Stefan
  • Don MDon M Posts: 1,653
    edited 2011-08-18 07:02
    Yes. I can live with the individual statements for now. They work fine.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-08-18 08:34
    You can't use the string() method with 9-bit values but you could put your commands into a DAT statement and create a method that iterates through them. Note that you need to terminate the group commands -- I'm using -1 in the example below as 0 may be a valid command in your system.
    [b]pub[/b] txmdb_str(pntr) | cmd
    
      repeat
        cmd := long[pntr]
        if (cmd == -1)
          quit
        else
          txmdbinv(cmd, MDB_MSTR)
          pntr += 4
    
    
    [b]dat[/b]
    
    Command1        long    $1_08, $0_08, -1
    

    Pass the address of the command string you want to send:
    txmdb_str(@Command1)
    
Sign In or Register to comment.