Shop OBEX P1 Docs P2 Docs Learn Events
Information on EB500 — Parallax Forums

Information on EB500

StereoPonyzStereoPonyz Posts: 82
edited 2010-02-19 06:19 in General Discussion
Hi, i have 3 eb500 each connected to·a BOE-Bot (rev c), which·I·wish·to use·them for communication. I found many examples on how to·establish connections between the bluetooths, however, they are using BS2 and was coded in PBasic.

I would like to find out where i may be able to find one manual that is based on Javelin. Also, if i need to place a bluetooth class in the lib first before coding it?
«1

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-12-28 09:06
    Here is a eb500 class and testfile.
    These must be stored in folder ...\lib\stamp\peripheral\wireless\eb500
    Create the eb500 folder if it does not exist.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2009-12-28 09:32
    THANK YOU, Peter [noparse]:)[/noparse]
    If there is by any chance a manual to code eb500 in java?

    INPUT 5

    'WAIT FOR the eb500 radio TO be ready
    PAUSE 1000

    'Connect TO the remote device
    SEROUT 1,240,[noparse][[/noparse]"CON 00:0C:84:00:54:F7",CR]
    SERIN 0,240,[noparse][[/noparse]WAIT("ACK",CR)]

    WaitForConnection:
    IF IN5 = 0 THEN WaitForConnection
    DEBUG "Connected",CR

    'WAIT FOR 20 seconds
    PAUSE 20000

    'I/O Line 6 allows us TO switch TO Command Mode
    OUTPUT 6

    'Switch TO Command Mode
    LOW 6
    SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]

    'Disconnect from the remote device
    SEROUT 1,240,[noparse][[/noparse]"dis",CR]
    SERIN 0,240,[noparse][[/noparse]WAIT(CR,">")]
    DEBUG "Disconnected",CR

    if instance, for the PBASIC codes abv, SEROUT means to send command via output pin 1 at 9600 baud. So to code in Java, i will use UART instead of SEROUT/SERIN and system.out.println instead of DEBUG?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-12-28 12:03
    You will find info in the files.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2009-12-31 05:17
    Sorry Peter, i encountered compiling errors. My directory (lib\stamp\peripheral) does not have a wireless folder, so i created one and in it i created eb500 folder and places the 2 attachments. But i cant compile.
    776 x 814 - 97K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-12-31 07:28
    The test file compiles and links on my pc, so I assume you must have
    made an error in creating the folders (you must use the exact names, no capital letters for example,
    and check for spaces at the end of folder name)
    or you did not place the files in folder eb500
    Please check.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-18 08:58
    Hi, Peter, i have 2 2b500 mounted each onto the Appmod of 2 Boe-Bot. I am trying to establish a connection between the bots. Am i right to say if i want Bot A to detect Bot B via bluetooth, i will just need to write codes into Bot A to do connection whle Bot B doesnt need? I have some confusion on how the connection is established between 2 bots.

    I have read the manual on eb500, and tried the codes (PBasic) shown in Step4: Connect the eb500-SER on the SumoBoard to the eb500-SER on the BOE, which is why i think only One Bot needed to be coded for purely one sided connection.

    Actually, i am trying to code BotA to keep feeding BotB with xpos and ypos, then Bot B·will move according to the parameters· based on some equations i had already tried out.

    The attached is the terminal o/p from trying some of your codes. I had tot after initialsing the eb500, it will print its own address out.

    ===================================================

    package stamp.peripheral.wireless.eb500;
    import stamp.core.*;
    import stamp.util.text.*;

    public class eb500Test {
    ··· static Uart EB500RX = new Uart(Uart.dirReceive,CPU.pin0, Uart.dontInvert, Uart.speed9600, Uart.stop1);
    ··· static Uart EB500TX = new Uart(Uart.dirTransmit,CPU.pin1, Uart.dontInvert, Uart.speed9600, Uart.stop1);
    public static void main(){
    ··· clearEB500Link();
    ··· eb500Connect();
    ··· }

    public static void clearEB500Link()
    {
    ··· // eb500 clear & Initialize
    ··· if (CPU.readPin(CPU.pin5) == true)
    ··· {
    ······· System.out.print("EB500 is alive in DATA mode, clearing.....");
    ······· // drive pin LOW
    ······· CPU.writePin(CPU.pin6,false);
    ······· CPU.delay(2000);
    ······· // disconnect
    ······· EB500TX.sendString("dis");
    ······· EB500TX.sendByte(13);
    ······· System.out.println("ok");
    ··· }
    ··· else
    ··· {
    ······· System.out.print("EB500 is alive in CMD mode, clearing.....");
    ······· EB500TX.sendByte(13);
    ······· EB500TX.sendByte(13);
    ······· System.out.println("ok");
    ······· return;
    ··· }
    }

    public static void eb500Connect() {
    ··· int data = 0;
    ··· EB500TX.sendString("get addr");
    ··· EB500TX.sendByte(13); // return
    // wait a tick
    CPU.delay(2500);
    while (EB500RX.byteAvailable() == true)
    {
    ··· System.out.print((char) EB500RX.receiveByte());
    }
    // connect
    System.out.print("Connecting.....");
    EB500TX.sendString("con XX:XX:XX:XX:XX:XX"); // address of the remote device
    EB500TX.sendByte(13);
    CPU.delay(5000);
    while (EB500RX.byteAvailable() ==true)
    {
    ···· data = (char) EB500RX.receiveByte();
    ···· if (data != ' ' && data != '\r')
    ···· {
    ········· System.out.print(data);
    ···· }
    }
    System.out.println("...ok");
    // wait for connection
    System.out.print("Wait for connection.....");
    System.out.println("ok!");
    System.out.println("Connection OK!");

    }
    }

    ===================================================
    632 x 277 - 26K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-19 09:38
    This line
    EB500TX.sendString("get addr");
    should be
    EB500TX.sendString("get address");

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-20 06:21
    Hi Peter, thank you for replying... I have changed the line into EB500TX.sendString("get address"); but the output is still the same as the attachment i had in the earlier post... I am not able to tell what is the address of the eb500.

    I read the info in your eb500.java, it says if the syntax is correct an ACK string or NAK string is returned, followed by a carriage return. I saw NAK> from the terminal which means the eb500 and Javelin are communicating. However, output is not right. The address of the eb500 is 00:0C:84:00:4E:C5.
    May i know if the eb500 (A) is able to stream data continously to another eb500 (B)?
    · public int sendCommand(int command, char chr) {
    ··· int k = assembleStart(command);
    ··· k = Format.bprintf(sendbuf,k," %c",chr);
    ··· k = assembleFinish(command,k);
    ··· esc = chr; //remember esc character
    ··· return send(k);
    · }

    this will be the code i have to implement? sorry i cannot understand how to apply...
    373 x 276 - 21K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-20 07:07
    The command to connect to 00:0C:84:00:4E:C5 is
    "con 00:0C:84:00:4E:C5 30" where the 30 is a timeout value.

    For my eb500 class, the commands would be

    · static Uart tx = new Uart(Uart.dirTransmit,CPU.pin2,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    · static Uart rx = new Uart(Uart.dirReceive,CPU.pin3,Uart.dontInvert,Uart.speed9600,Uart.stop1);

    · static eb500 eb = new eb500(rx,tx,CPU.pin0,CPU.pin1);
    · static String addr = "00:0C:84:00:4E:C5";
    · static String name = "devicename";
    · static String key = "1234567890";
    · static int timeout = 30;

    · static void main() {
    ··· eb.sendCommand(eb.Connect,addr,timeout);
    ··· while (!eb.response()) ;
    ··· eb.print();
    ··· eb.sendCommand(eb.ReturnToDataMode); //enter data mode
    ··· while (!eb.response()) ;
    ··· eb.print();
    ··· //once connected and in data mode, use·tx.sendByte() to send data,·rx.receiveByte()·to receive data
    ··· //other code
    ·· while (true) ;
    · }

    If all is well, the responses should be ACK>\r
    which is printed by eb.print()

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-20 15:05
    Hi Peter, i have used Uart for StarGazer that is reading Pin2
    static Uart myUart = new Uart(Uart.dirReceive,CPU.pin2,Uart.invert,Uart.speed9600,Uart.stop1);

    Can i use other pins for eb500? like pin4 and 5?

    static Uart tx = new Uart(Uart.dirTransmit,CPU.pin4,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    static Uart rx = new Uart(Uart.dirReceive,CPU.pin5,Uart.dontInvert,Uart.speed9600,Uart.stop1);

    static eb500 eb = new eb500(rx,tx,CPU.pin0,CPU.pin1);


    May i know if the abv segment of codes is to detect eb500 mounted on Another Bot which has an address of "00:0C:84:00:4E:C5", not for reading its Own eb500 address?

    I have tried out the codes, however, it has no output. Where should i place the connect command, "con 00:0C:84:00:4E:C5 30" ?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-20 18:56
    If you stick the eb500 to the appmod header on the Board of Education
    or Javelin Demoboard, then you must use the pins as given in the manual.

    · static Uart tx = new Uart(Uart.dirTransmit,CPU.pin1,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    · static Uart rx = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    · static eb500 eb = new eb500(rx,tx,CPU.pin5,CPU.pin6);

    If you do not stick the eb500 on the appmod header, then you can use other pins
    by using wires from the eb500 connector to the appmod header.

    The get address command should return the address of the eb500 that is
    directly connected. Once you know the address of the other eb500 module,
    that is the address used in the connect command.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-21 05:16
    Hi Peter, i am able to receive ACK> already.
    Sometimes it will return error msg like: ACK>
    ····························································· err3

    I looked into your eb500.java·for info but i am not sure what err3 is.



    Post Edited (StereoPonyz) : 1/21/2010 5:24:24 AM GMT
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-21 06:11
    import stamp.peripheral.wireless.eb500.*;
    import stamp.util.text.*;
    import stamp.core.*;

    public class eb500Test3 {
    · static Uart tx = new Uart(Uart.dirTransmit,CPU.pin1,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    · static Uart rx = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed9600,Uart.stop1);

    · static eb500 eb = new eb500(rx,tx,CPU.pin5,CPU.pin6);
    · static String addr = "00:0C:84:00:4E:C5";
    · static int timeout = 30;
    · static String OwnAddr = "00:0C:84:00:54:F7";

    · static byte xpos = 55;

    · static void main() {
    ··· eb.sendCommand(eb.Connect,addr,timeout);
    ··· while (!eb.response()) ;
    ··· eb.print();·//......................................................................................ACK
    ··· eb.sendCommand(eb.ReturnToDataMode); //enter data mode
    ··· while (!eb.response()) ;//..................................................................Keep Looping
    ··· eb.print();
    ··· eb.sendCommand(eb.SetBaud9600);
    ··· System.out.println("Baud Rate is set to 9600");
    ··· tx.sendByte(xpos);
    ··· System.out.println("xpos is sent over");
    ··· //once connected and in data mode, use tx.sendByte() to send data, rx.receiveByte() to receive data
    ··· //other code
    ·· while (true) ;
    · }

    }

    ==========================================================================

    Hi Peter, from the abve code i can receive ACK followed by >·But it is not able to execute my other·commands..

    I had used debugger to step thru the codes, i realised that it keeps looping ard the while cond for the·second sendcommand.

    Post Edited (StereoPonyz) : 1/21/2010 6:44:47 AM GMT
    680 x 277 - 19K
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-21 06:41
    Oh Peter... am i right to say for the abv codes to work, i need 2 bots to transmit and receive?

    Like Bot(A) connect to BOT(B), once it is successful, BOT(B) will send "ACK" to BOT(A) to print out.
    As for the tx.sendByte command BOT(B) must receive it, so that it can send "ACK" back to BOT(A) for print out? Means that BOT(B) must have codes that is waiting to receive Byte?

    My serial cable to connect to BOT(A) for javelin terminal output.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-21 10:31
    After reading some bs2 examples, I believe the eb500 enters data mode after
    succesful connection.

    So,

    public class eb500Test3 {
    · static Uart tx = new Uart(Uart.dirTransmit,CPU.pin1,Uart.dontInvert,Uart.speed9600,Uart.stop1);
    · static Uart rx = new Uart(Uart.dirReceive,CPU.pin0,Uart.dontInvert,Uart.speed9600,Uart.stop1);

    · static eb500 eb = new eb500(rx,tx,CPU.pin5,CPU.pin6);
    · static String addr = "00:0C:84:00:4E:C5";
    · static int timeout = 30;
    · static String OwnAddr = "00:0C:84:00:54:F7";

    · static byte xpos = 55;

    · static void main() {
    ··· eb.sendCommand(eb.Connect,addr,timeout);
    ··· while (!eb.response()) ;
    ··· eb.print();·//......................................................................................ACK

    At this point, if ACK was received (and you should check the receive buffer, meaning
    adding a method to the eb500 class to compare receive buffer against string)
    the eb500 entered data mode.

    ·· while (!CPU.readPin(CPU.pin5)) ; //wait until pin5 is high (= datamode)
    ·· tx.sendString("this text is sent to a remote receiver via eb500");


    You should indeed have the remote receiver in data mode to receive the above text string.
    Check the manual for communication via 2 eb500 modules.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-22 14:30
    Hi Peter, how to receive and Print the data sent by other Bot? For Bs2, the command to Print is SERIN 0,84,[noparse][[/noparse]STR szData\17]. I look under the eb500.java, it does not have a command that will print the exact data sent, except eb.print() which only print ACK. My Bot B printed 2 ACK. 1 ACK is for successful connection to BOT A, another ACK is successful receive of Byte? Am i correct this is the way it works?

    Can i also know if 2 Bots need to have the codes ( eb.sendCommand(eb.Connect,addr,timeout); ) to connect to each other, or just one Bot is needed?

    Below are the 2 individual codes loaded into the respective Bots.
    ================================================================================================

    <<Codes loaded in BOT A>>
    static void main() {
    eb.sendCommand(eb.Connect,addr,timeout);
    while (!eb.response()) ;
    eb.print();
    eb.sendCommand(eb.GetName);
    eb.print();
    while (!CPU.readPin(CPU.pin5)) ; //wait until pin5 is high (= datamode)
    tx.sendString("this text is sent to a remote receiver via eb500");
    Format.printf("Test is sent over\n");
    tx.sendByte(xpos);
    Format.printf("Byte sent over\n", xpos);
    while (true) ;
    }

    <<Codes loaded in BOT B>>
    static void main() {
    eb.sendCommand(eb.Connect,addr,timeout);
    while (!eb.response()) ;
    eb.print();
    rx.receiveByte();
    eb.print();
    while (true) ;
    }
    373 x 277 - 12K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-22 15:47
    Try this

    <<Codes loaded in BOT B>>
    static void main() {
    eb.sendCommand(eb.Connect,addr,timeout);
    while (!eb.response()) ;
    eb.print();
    int receivedData = rx.receiveByte();
    Format.printf("Received Data = %d\n",receivedData);

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-23 08:50
    Hi Peter, it seems to have problem receiving the byte properly... No matter what values i set in Bot A, when it was received and print by BOT B, the output is always 103...
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-28 07:24
    Peter, may i enquire what may be the prob for the wrong result output??
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-28 14:37
    Apparently the 2 modules don't enter data mode together. I assume the 103
    is some respond byte.

    Best advice is to take the BS2 example from the manual and convert it
    to javelin. Test and adapt the javelin code until you get the same results
    as the BS2 program. I would start with one eb500 module and a pc blue tooth
    adapter to get data to and from hyperterminal.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-28 16:43
    Hi Peter, i have read through the manual. There are something which i am confuse of.

    SEROUT 1,84,[noparse][[/noparse]"get address",CR]
    :SEROUT-->Output Data
    :1--> “P1” of the AppMod header, is the UART data input pin.

    that line means to output data using uart input pin? quite confusing, it had to output data need to use UART output pin.



    Next, For printing outputs, BS2 always use this code --> SERIN 0,84,[noparse][[/noparse]STR szData\17]. What may be the conversion for Javelin?

    Post Edited (StereoPonyz) : 1/28/2010 5:29:56 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-29 12:34
    From the manual:

    Pin out
    The eb500 module features a 20 pin connector with 0.1” spacing for direct connection to a
    Parallax AppMod header. Currently, nine of the pins are in use (seven when flow control is
    set to none). The other pins are reserved for future use.
    Pin Parallax Pin Function Description Usage
    CN1 - 1 GND GND Ground Required
    CN1 - 2 GND GND Ground Required
    CN1 - 3 P0 TX Serial Transmit line from eb500 Required (so javelin receives at P0)
    CN1 - 4 P1 RX Serial Receive line to eb500 Required (so javelin transmits at P1)
    CN1 - 5 P2 RTS Request-to-Send on the serial port interface between the eb500 and the BASIC Stamp Optional
    CN1 - 6 P3 CTS Clear-to-Send on the serial port interface between the eb500 and the BASIC Stamp Optional
    CN1 - 8 P5 Status Bluetooth connection status (0 = not connected, 1 = connected) Required
    CN1 – 9 P6 Mode Command/data mode toggle (0 = command, 1 = data) Required
    CN1 - 20 VCC VCC Power Required
    Table 4: eb500 Pin out Description
    So it appears pin0 must receive, and pin1 must transmit.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-01-30 05:17
    Thank you Peter for the clarification.

    Post Edited (StereoPonyz) : 2/1/2010 3:18:13 AM GMT
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-01 03:23
    Hi Peter, i would like to send interger from Stargazer instead of byte. I had used -

    (BOT A)·····
    ························<<Stargazer Codings>>

    ······················· int a = xpos/100;
    ························ byte b =(byte)a;
    ················· ·· ··· eb.sendCommand(eb.Connect,addr,timeout);
    ·························tx.sendByte(b);

    (BOT B)

    ··· eb.sendCommand(eb.Connect,addr,timeout);
    ··· while (!eb.response()) ;
    ··· eb.print();
    ··· int receivedData = rx.receiveByte();
    ··· Format.printf("Received Data = %d\n",receivedData);

    The result shown in Bot B is always 99. When in fact Stargazer showed xpos as 21.86


    I also tried tx.sendInteger(xpos); apparently there isnt such command.

    Post Edited (StereoPonyz) : 2/1/2010 4:16:16 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-02-01 12:30
    To send an integer you must transmit lowbyte followed by highbyte

    tx.sendByte(value); //send lowbyte
    tx.sendByte(value >> 8); //send highbyte

    To receive an integer, you must receive lowbyte and highbyte and assemble

    int lowbyte = rx.receiveByte(); //receive lowbyte
    int highbyte = rx.receiveByte(); //receive highbyte
    int value = (highbyte << 8) | (lowbyte & 0xFF);

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-01 16:40
    Hi Peter, if i need to send 2 Bytes (xpos and ypos) at the same time. What command do i use to read both of the Bytes individually?

    Like in the case for Bot B, the commands for receiving the bytes are similar, rx.receiveByte().
    How do i make it such that int lowbyte and int highbyte belongs to xpos, and int lowbyte2 and int highbyte2 belongs to ypos? Do i add argument inside the receive command brackets?

    I had created 2 UART tx1, rx1 and tx2, rx2 for individual x and y bytes but it cant work... Both are printed out as xpos bytes.
    ======================================================================================
    (Bot A)
    int x = xpos/100;
    byte valueX =(byte)x;

    int y = ypos/100;
    byte valueY =(byte)x;

    tx.sendByte(valueX); //send lowbyte
    tx.sendByte(valueX >> 8); //send highbyte

    tx2.sendByte(valueY); //send lowbyte
    tx2.sendByte(valueY >> 8); //send highbyte

    (Bot B)
    int lowbyte = rx.receiveByte(); //receive lowbyte
    int highbyte = rx.receiveByte(); //receive highbyte
    int valueX = (highbyte << 8) | (lowbyte & 0xFF);

    Format.printf("Received Data = %d\n",valueX);

    int lowbyte2 = rx2.receiveByte(); //receive lowbyte
    int highbyte2 = rx2.receiveByte(); //receive highbyte
    int valueY = (highbyte << 8) | (lowbyte & 0xFF);

    Format.printf("Received Data = %d\n",valueY);

    Post Edited (StereoPonyz) : 2/1/2010 4:56:12 PM GMT
    714 x 601 - 63K
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-02-01 16:49
    You need some synchronisation.
    For example, you could send
    "!eb",xpos,xpos>>8,ypos,ypos>>8

    On the receiver side, you then wait for reception of "!eb",
    after which follow 4 bytes that make up the integers xpos and ypos.

    regards peter
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-01 16:59
    Hi Peter, I had created 2 UART tx1, rx1 and tx2, rx2 for individual x and y bytes but it cant work... Both are printed out as xpos bytes.

    Sorry i dont understand the synchronisation method...

    Do you mean: tx.sendByte("!eb",xpos,xpos>>8,ypos,ypos>>8) Has error...

    I also tried: tx.sendByte("!eb",xpos,xpos>>8) Has error...
  • StereoPonyzStereoPonyz Posts: 82
    edited 2010-02-02 03:48
    Peter can you explain again?? my java knowledge is very basic... thank you...

    What does '!eb' mean?

    Post Edited (StereoPonyz) : 2/2/2010 4:12:10 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-02-02 13:00
    I meant like this

    //on transmitter bot
    int xpos,ypos;

    tx.sendString("!eb");
    tx.sendByte(xpos);
    tx.sendByte(xpos>>8);
    tx.sendByte(ypos);
    tx.sendByte(ypos>>8);

    //on receiver bot
    int xpos,ypos;

    void receiveXY() {
    · int state = 0;
    · int c;
    · while (true) {
    ··· switch (state) {
    ····· case 0: //wait for !
    ················ c = rx.receiveByte();
    ·················if (c == '!') state = 1;
    ················ break;
    ····· case 1: //wait for e
    ················ c = rx.receiveByte();
    ·················if (c == 'e') state = 2;
    ················ else if·(c != '!') state =·0;
    ················ break;
    ····· case 2: //wait for b
    ················ c = rx.receiveByte();
    ·················if (c == 'b') state = 3;
    ················ else state = 0;
    ················ break;
    ····· case 3: //get xpos lowbyte
    ················ xpos = rx.receiveByte();
    ·················state = 4;
    ················ break;
    ····· case 4: //get xpos highbyte
    ················ xpos |= (rx.receiveByte() << 8);
    ·················state = 5;
    ················ break;
    ····· case 5: //get ypos lowbyte
    ················ ypos = rx.receiveByte();
    ·················state = 6;
    ················ break;
    ····· case 6: //get ypos highbyte
    ················ ypos |= (rx.receiveByte() << 8);
    ················ return; //at this point the·function returns
    ··· }
    · }
    }

    receiveXY() waits for "!eb" and then sets xpos and ypos.
    It should be called after establishing data mode.

    regards peter

    Post Edited (Peter Verkaik) : 2/2/2010 1:06:43 PM GMT
Sign In or Register to comment.