Results 1 to 6 of 6

Thread: Serial device development; getting 'self' in a callback

  1. #1
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default Serial device development; getting 'self' in a callback

    Currently developing a serial driver using the queued serial object.

    The callback methods for receiving data, do not include the 'self' parameter. Now if I want to set some values on the object, based upon the received answer, I need access to 'self' (not?).

    How to go about getting a reference to 'self' in this case? or is there another (preferred) way of achieving this?

    any help is greatly appreciated
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  2. #2
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    You shouldn't be using callbacks, that will interfere with the normal operation of the serial device.

    Just override the ReceiveResponse method but be sure to call the inherited method from within it.

    Having said all that the serial classes are really deprecated these days in Girder 5, it's generally better to implement your device using the transport classes if you can. If you're using Girder 4 then you're stuck with the serial classes though.
    --Rob

  3. #3
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Hi Rob,

    thx for the feedback. I've searched the help files on the transport stuff but couldn't find anything (as opposed to the serial stuff). Seems to me the documentation is really outdated? (has it even changed since Girder 4?)

    any way; can you point me to some documentation or examples on creating drivers for a serial connected device using the transport stuff?

    thx!
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  4. #4
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Just found the documentation, after checking the site, the manual was an updated one. I was still running one of the early Girder 5 versions. Installed the newer version and all docs are there.
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  5. #5
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Question

    Quote Originally Posted by Rob H View Post
    You shouldn't be using callbacks, that will interfere with the normal operation of the serial device.

    Just override the ReceiveResponse method but be sure to call the inherited method from within it.
    I'm sticking to the serial device for now, using the queued object. Checked the help files on this;
    Queued Sending
    If the device driver object is based on serial.Classes.Queued rather than serial.Classes.Simple, then a more advanced version of SendCommand is available. This stores messages and response functions on a queue. Behind the scenes, the command is sent and when a response arrives the response function is called. Then the next command is sent and so on. It is not necessary to provide a ReceiveResponse replacement.
    It explicitly states that no override of "ReceiveResponse" is required, as opposed to your statement. What's the caveat?

    The original question stays; how to get a reference to 'self' inside the callback method provided to the 'SendCommand'?
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  6. #6
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    ReceiveResponse override isn't required, but it is still the recommended way of handling responses.

    As I said, do not use callbacks with the serial classes, it will break the operation of the serial device.
    --Rob

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •