PDA

View Full Version : gir_event problems



denmike
July 21st, 2005, 03:56 PM
Hi all,

it looks like I've got a plugin to work - well mostly. I'm having some problems with the most important part - doing something when an action should take place.

I can't seem to find any documentation on what the different parts of command is doing. Or what the status field is used for. Can you help?

Currently my function looks like this, but when no action is selected I get an exception (is it possible to debug this stuff at all, or have you disabled debuggers ??). Also it seems that the wrong action is sometime transmitted to my plugin... Can I expect that gir_event is only called when it is something for me, or do I have to check command.actiontype?

function gir_event(command: p_command; eventstring: PChar; payload: Pointer; len: integer; status: PChar; statuslen: integer): integer; stdcall;
begin
gir_event := 0; // ret_continue
if command = nil then exit; // is this necessary?
if command.actionType <> PLUGNUM then exit; // is this necessary?
EnterCriticalSection(Command.critical_section);

// transmit serial data to the device
// Comm.SendString(CurCommand.sValue1);
application.messagebox(CurCommand.sValue1, 'a', mb_Ok); // this gives an exception
LeaveCriticalSection(command.critical_section);
end;

What am I supposed to do in gir_event? Ok, I know that I should transmit data to my equipment, but what do I need to check for?

Any help greatly appreciated.
Any pointer to some proper API documentation also much appreciated.

//michael

birty
July 21st, 2005, 04:04 PM
there is not much in the way of documentation for g3, g4 is much better, there is a sample delphi plugin in the downloads section, try this code:

function gir_event&#40;command&#58; p_command; eventstring&#58; PChar; payload&#58; Pointer; len&#58; integer; status&#58; PChar; statuslen&#58; integer&#41;&#58; integer; stdcall;
var cmd&#58;string;
begin
try
EnterCriticalSection&#40;Command.critical_section&#41;;
cmd&#58;=command.sValue1;
//get any other values, sValue2, iValue1 etc. here
LeaveCriticalSection&#40;command.critical_section&#41;;
//do something here
except on e&#58;exception do &#123;handle error here&#125;
end;
result&#58;= retcontinue;
end;

denmike
July 22nd, 2005, 09:17 AM
Doh, it turned out that I was using a global variable due to at typo. This is funny, because that is one of the reasons I try to teach my students always to avoid using global variables. However my plugin is based on a sample Delphi plugin - and I wasn't careful enough :-?

So my problem is solved, however I could still need some information on:

- Is it possible to debug plugins at all, or have you disabled debuggers (so it seems)?
- Can I expect that gir_event is only called when it is something for me, or do I have to check command.actiontype for the correct plugin-number?
- What is the status (and statuslen) field(s) used for?
- Can gir_event be called with a nil/null command structure?

I'm still messing around with G4alfa (the second to last if I remember correctly) - I don't think the documentation has improved a lot since G3. Is it better in the beta?

//michael

Ron
July 22nd, 2005, 09:42 AM
Sorry no debugging allowed.

yes gir_event will only be called if the message is for you.

status and statuslen is a buffer and its size that girder give you to give feedback to Girder about the action.

gir_event should never be called with a nil argument.

Btw, I would strongly suggest using G4 as your development target, G3 will be discontinued in the not so distant future.

Last G4 release is BETA 4.

denmike
July 22nd, 2005, 10:53 AM
> Sorry no debugging allowed.

Bummer. That is FUed - makes it much more difficult to develop a plugin :(

> yes gir_event will only be called if the message is for you.
> gir_event should never be called with a nil argument.

excellent!

> status and statuslen is a buffer and its size that girder give you to give feedback to
> Girder about the action.

ok, I guess I don't need that.. is it put in the status bar, or what is it used for?

> Btw, I would strongly suggest using G4 as your development target, G3 will be
> discontinued in the not so distant future.

Yeah well, G4 is very expensive compared to G3, and we figure that a number of users won't be upgrading. Anyways afaics I can reuse most of the plugin for a G4 version. Which I will start looking into shortly :)

Thanks for info!

//michael

birty
July 22nd, 2005, 11:35 AM
i find that while girder 4 runs a bit slowly under the delphi debugger it is still possible to run with the debugger.