Home AMX User Forum NetLinx Studio

IP conections in modules

I have problem with defining local port for ip connection, when this connection inside the module. If something like that:

DEFINE_DEVICE
vdvIPdev=0:FIRST_LOCAL_PORT+41:0
DEFINE_START
DEFINE_MODULE 'aaa' sdfds(vdvIPdev)

, i recive "ERROR: (0): C10580: Internal Error: Major system error occurred during code generation ".
but if i write
DEFINE_DEVICE
vdvIPdev=0:44:0

it is ok.
Why thirst variant gives this error?

Comments

  • Spire_JeffSpire_Jeff Posts: 1,917
    I would avoid declaring the IP port within the module. I would recommend passing in a device instead. First off, you don't want to be skipping a bunch of ports for no reason as the processor allocates resources for every port from 1 to x where x= highest port used if I recall correctly. Second, unless you desire this, multiple instances of the module would conflict with each other. Lastly, if a programmer gets two different modules that both happened to pick the same port, they would have to choose one or the other unless they have source code (unless they aren't aware of the ports being used, then they would just wonder why the modules work intermittently :) ).

    As for the FIRST_LOCAL_PORT, I have stopped using it all together because of problems similar to what you describe. There is no advantage to using FIRST_LOCAL_PORT as it is just a constant value of 1 or 2 (don't recall which). It would be nice if, on load, the processor could assign a port to each IP device, but NetLinx just doesn't allow it. At least now I have the IR file assignment window that I can arrange by device so I can see if I declared unique ports for everything :)

    Not sure if this helps or answers your question, but I suppose the old joke would work best here.... Guy walks into a doctor's office and says "Doc, it hurts when I pinch my arm. What should I do?". The doctor says "Stop pinching your arm!". (Just do it the second way :) )

    Jeff
  • truetrue Posts: 307
    Spire_Jeff wrote: »
    I would avoid declaring the IP port within the module.

    He isn't.

    white, try putting your FIRST_LOCAL_PORT bit in parenthesis, forget using FIRST_LOCAL_PORT, or define it in a variable.
  • DHawthorneDHawthorne Posts: 4,584
    For the record, you never want to define a device, IP or otherwise, inside a module. The point of modules (the main one at least), is to have transportable code you can move from job to job, and you might need to use that module in a job that is already using that port. That's not so bad in itself, you can always re-assign; it's trying to determine what ports are free that becomes the nightmare. If they are all in one place in your main code, it is far, far easier to manage without duplicates than having it spread out in a dozen modules.
  • whitewhite Posts: 7
    Thanks for all.
    I define device outside of the module, but connection initiates inside module.

    Now, I don't use FIRST_LOCAL_PORT, but I think what things like
    DEFINE_DEVICE
    dvIPDev=0:1+1:0
    DEFINE_MODULE some_module 'module1' (dvIPDev)
    must work in NetLinx compiler .
Sign In or Register to comment.