Shop OBEX P1 Docs P2 Docs Learn Events
RealBasic to Propeller — Parallax Forums

RealBasic to Propeller

T ChapT Chap Posts: 4,223
edited 2006-10-22 19:31 in Propeller 1
I am working on a RealBasic app that will send data to a Propeller. I am really confused on how to do this, maybe someone could understand what is the snag and clarify this stuff.

The data to be sent from RB to the Prop in one string:

MotorNumber1 byte
MotorNumber2 byte
MotorNumber3 byte
MotorNumber4 byte
Distance A long(possible word)
Distance B long "
Distance C long "
Distance D long "
ControlA 1-15 possibilities of numbers byte
ControlB 1-15 possibilities of numbers byte
Control 1 byte
" "
" "
Control 15 byte


Here is the motorMove method I was trying to make work, a scaled down version that is.

motorNumber As Integer, distance as integer

  Dim msg As New MemoryBlock(4)
  
  msg.Byte(0) =  motornumber   'works when  looking for a number/text but not bin
  
  msg.Byte(1) = distance
  
  msg.Byte(2) =1000
  
  msg.Byte(3) = &b11110000     ' test
  
  serial1.Write msg




From what I can tell, the RB will send a binary byte like this, and the Stamp will receive it as a binary: &b00000000. However, I cannot find a way to set a variable to be a binary in RB, but I can just serial.write &b00000000 and it works. I get errors of mismatch when attempting to change the method to motormove as binarystream.

Now to the Propeller, it would really be helpful to find out how I am even going to deal with the data once I do get it in a format. In testing with the BS2p40, this seems to be a workable concept:

'read the byte(11)
if byte(0) = 0 then  'we are dealing with motor 1, therefore
byte(1) = the distance to move motor 1 by the Props motorMove method
byte(2) = the distance to move motor 1 by the Props motorMove method
etc etc for all motors, all controls




How to get a long value integer out of RB and reasembled in the Prop for use in the distance value? who knows

Right now the biggest question is to narrow down whether to use hex, bin, dec etc.

I am too tired to make a point.

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2006-10-22 14:49
    msg.Byte(2) =1000 <--- 1000 will not fit into a byte

    Best,

    Bill
  • T ChapT Chap Posts: 4,223
    edited 2006-10-22 18:18
    Yes that is the problem. I am realizing that there is no way to have a nice tidy array that holds everything. All data must be sent separately, as the values can range from 0 to longs on some parameters, and no way to package various values up in one fixed size array.

    Post Edited (originator99) : 10/22/2006 7:14:14 PM GMT
  • Bill HenningBill Henning Posts: 6,445
    edited 2006-10-22 19:31
    sure there is. you can put smaller items into bigger ones - use an array of longs
Sign In or Register to comment.