Home AMX User Forum AMXForums Archive Threads AMX Hardware Feature Requests

Netlinx Buffer

I would like the ability to have a Netlinx module have a dynamic device passed into the module. I tried various ways of doing this but the buffer allocation will always attach to the original device passed into the module. I could decalre modules and have the users the ability to choose the type of device on the port not using Duet.

So an API call to reallocation the buffer to the device in Netlinx.

John

Comments

  • ericmedleyericmedley Posts: 4,177
    jgreer9514 wrote: »
    I would like the ability to have a Netlinx module have a dynamic device passed into the module. I tried various ways of doing this but the buffer allocation will always attach to the original device passed into the module. I could decalre modules and have the users the ability to choose the type of device on the port not using Duet.

    So an API call to reallocation the buffer to the device in Netlinx.

    John
    Variables are passed into a Netlinx module by reference. So, what the value is at startup is whats passed. To get dynamic info in you're going to have to do it by other means.

    The easiest way that comes to mind is to create a command protocol and send commands to a virtual device created for the module.

    Something along the lines of

    send_command vdv_my_vDevice,"NEW_Device_Num:123:1:0

    Then in the module you'd parse the string and reference the device with the new values.

    It's going to be tricky in that events get ugly when trying to alter devices.
  • jjamesjjames Posts: 2,908
    ericmedley wrote: »
    Variables are passed into a Netlinx module by reference. So, what the value is at startup is whats passed. To get dynamic info in you're going to have to do it by other means.
    Are you sure? I pass a variable over to my JSON parser and then parse directly on that within the module. It's here on the forum (and I think I posted the source code) if you want to look.

    So couldn't in the main program the device number would be a DEV var and when it changes in main code, it changes in the module?

    Or maybe, I'm just not quite following . . .
  • jgreer9514jgreer9514 Posts: 23
    buffer

    If you have a device declared and passed into the module and change it within your program there is no way to make the module re-sync the buffer with the new device. There is for touch panel events but not for the data event.

    =(
  • jjamesjjames Posts: 2,908
    Curiously - is this a TPControl feature request? I'm not sure what they'd be able to do about. Again, perhaps posting this in the proper sub-forum would be of help.
  • AMXJeffAMXJeff Posts: 450
    jgreer9514 wrote: »
    I would like the ability to have a Netlinx module have a dynamic device passed into the module. I tried various ways of doing this but the buffer allocation will always attach to the original device passed into the module. I could decalre modules and have the users the ability to choose the type of device on the port not using Duet.

    So an API call to reallocation the buffer to the device in Netlinx.

    John

    If you stay way from buffers and use DATA_EVENT this is easily done.
    // INSIDE MODULE
    DEFINE_EVENT
    DATA_EVENT[vdvDeviceID]
    {
         STRING:
         {
            // DO BUFFER PARSING HERE...
         }
    }
    
    DEFINE_PROGRAM
    
    if (vdvNewDeviceID != vdvDeviceID)
    {
        vdvDeviceID = vdvNewDeviceID;
    
       REBUILD_EVENT();
    }
    
    
  • I'm still not 100% sure exactly what you're trying to do but it sounds like you might just want to try using DYNAMIC_VIRTUAL_DEVICE. This will dynamically assign a device number in the 36,864+ address range. You'll guarantee a unique device number

    Ex.

    DEFINE_DEVICE

    vdvDynVirtual = DYNAMIC_VIRTUAL_DEVICE
  • lasthuman wrote: »
    I'm still not 100% sure exactly what you're trying to do but it sounds like you might just want to try using DYNAMIC_VIRTUAL_DEVICE. This will dynamically assign a device number in the 36,864+ address range. You'll guarantee a unique device number

    Ex.

    DEFINE_DEVICE

    vdvDynVirtual = DYNAMIC_VIRTUAL_DEVICE
    Looking at the Netlinx.axi the DYNAMIC_VIRTUAL_DEVICE is statically assigned with a device number of 36864:1:0. Unless this device number is an alias for assigning a new device number then one will end up declaring many instances of the same device (?).

    Kostas
Sign In or Register to comment.