Arduino Modbus Slave

Hi All- I'm attempting to use the modbus slave library from here:

Unfortunately I such a noob I'm not seeming to implement it correctly. The zip contains modbuslave.h and modbuslave.cpp. I am used to loading a .pde file. the .h file has what looks like a arduino sketch. But when i paste it into IDE and try to compile it throws all kinds of errors. It also calls(includes) the .h file so that seems circular and not correct to me.

I've been reading and googling for a bunch of hours now and each time I think I get it I dont.

Can somebody give me some tips to get this to actually compile so I can get to the next step in my hobby project? :'(

so every time im about to put this thing back on the shelf for another few months I break through.
I was able to get this to compile: using modbusslave from here:
in modbusslave.cpp theres a sample sketch. After commenting out the … it compiles.

#include <ModbusSlave.h>
//Arduino sketch example with 2 holding regs:

void setup() 
        /* Modbus setup example, the master must use the same COM parameters */
        /* 115200 bps, 8N1, two-device network */
        init_mb_slave(115200, 'n', 0);

void loop() 
    /* This is all for the Modbus slave */
    start_mb_slave(MB_SLAVE, regs, MB_REGS);

    /* your code goes here */
 //   ...
    /* handle write event */
    if (written.num_regs) {
   ///     ....

whoo hoo.

Now obviously I’m supposed to put something in the “your code here” areas.

Sooooo, what goes there?
If I could find any kind of docs or somewhere to start but my searches dont bringup anything helpful.
My end game is to communicate with Mango

For posterity's sake: is a full working example on Arduino ModBusSlave and Mango.

Thanks for the walkthrough, this made everything really easy.

Just wondering if you know how to bring back more than one variable. I have tried setting up a second register eg. regs[MB_REG1]=x,

but it seems to make Mango Unresponsive and my comm port disappears under the data source settings.

I like the mango interface, but bringing back only one variable seems like a waste.

Any ideas?

I got as far as writing that tutorial and realized I didnt want to use Mango. Switched to PHP serial and havent looked back. The mango forums are pretty good. you may want to ask over there.

Thanks anyways, I will give that a try.