Connecting to Gamoto motor controller

Hi~

I want to connect the Arduino (or maybe Wiring since it has 2 serial ports) to this Gamoto motor controller:

http://www.gamatronix.com/product_info.php/products_id/28

There is C++ example code near the bottom of the page (too long to post here but here's a link:)

http://www.gamatronix.com/gamoto/software/GamotoObject.zip

I am almost able to compile this code as a library in Arduino/Wiring - except the example code has a dependency (as an #include) on some C++ WIN serial stuff that I don't want to use. It basically sets up a COM port on a Windows machine, etc.

The Arduino compile is failing on these routines (below) - which essentially do what Serial.read and Serial.print do. Can I create a Serial object in this code through a '#include "WProgram.h"?

Oh - while I am here: this Gamoto code uses DWORD - I looked it up and that seems eq. to a long. Is that correct?

Thanks for any tips! I'll be tinkering away at this but I figured I ask before I burn too much time.

--Roy

UINT WriteBytes(unsigned char * lpBuf, DWORD dwToWrite)
{
      // Writes some bytes out the COM port.  Returns 0 if successful, error code of LastError if not
      // lpBuf = pointer to array of bytes
      // dwToWrite = how many bytes to write

      DWORD dwWritten;
    //
    // issue write
    //
      if (!WriteFile(COMDEV(TTYInfo), lpBuf, dwToWrite, &dwWritten, NULL))
            return GetLastError();
      else
        return (0);
}

UINT WriteString(char* wstr){
    //writes a zero-terminated string to the com port
    return (WriteBytes((unsigned char*)wstr,(DWORD)strlen(wstr)));
}

UINT ReadByte(unsigned char* lpBuf,DWORD * dwRead) {
      // Read byte from the COM port
      // Returns 0 if successful
      // dwRead = number bytes that were actually read, this is set by the ReadFile routine
    // for this function, dwRead will be either 0 or 1
//      UINT result;   //return value from this function (0 = OK, else error code)
      if (!ReadFile(COMDEV(TTYInfo), lpBuf, 1, dwRead, NULL))
        return GetLastError();
      else return 0;
}      

UINT ReadBytes(unsigned char* lpBuf,DWORD * dwRead,int maxsize) {
      // Read multiple bytes from the COM port
      // Returns 0 if successful
      // dwRead = number bytes that were actually read, this is set by the ReadFile routine
    // maxsize = maximum number of bytes to read (MUST be <= size of lpBuf passed in)
    // NOTE: buffer (lpBuf) is not returned with a zero terminator (not a string)
//      UINT result;   //return value from this function (0 = OK, else error code)
      if (!ReadFile(COMDEV(TTYInfo), lpBuf, maxsize, dwRead, NULL))
        return GetLastError();
      else return 0;
}

Hi Again,

My previous post might have been a bit muddled - the gist of it is that I need to talk to this motor controller in hex - and I don't know how to do that. Here's an example:

I get some of it but not enough to get functional with it.
Could someone translate this example into what I might send through the Arduino:

--what is the $ for?
--how is the checksum derived? (sort of assuming I calculate it)

If possible, show how it would look in the Arduino/Wiring code

--what is the $ for?

It signifies that what follows is a hex number. This is normally indicated by 0x but I have seen $ used before.

--how is the checksum derived? (sort of assuming I calculate it)

Add up all the numbers you have in the 4 bytes indicated and then just take the least significant byte of the result. For example suppose these were in variables B1 to B4 then
check = (B1 + B2 + B3 + B4) & 0xff;