IO Unit Name for use in MemMap Command

Small one that was bugging me yesterday, couldn’t find an answer:

I am in the process of implementing a ping feature to run periodically on one of my R2’s.

At first, I attempted to implement the ping example code found here on the forums as a subroutine, for built-in flexibility.

But I hit a snag, I can’t find any way to get the same of an IO unit for use in the MemMap function calls, and even if I pass said name as a parameter of my function, won’t it not accept a string of said IO unit name b/c it sees it as a string and not an “IO unit” type?

Is there a pointer-based solution that I am missing perhaps?

The name of the controller or EB is not used in anyway shape or form for networking.
You MUST use the IP address of the rack.

So no, I don’t think you are missing anything. You simply cant use the name.

I have ran into this issue of wanting to write a subroutine to work with any IO Unit. Unfortunately, there is no “generic” IO unit type that allows you to pass any type of IO unit to a subroutine. However, there is a work around that I found:

If you setup one of your parameters as a Generic OptoMMP Device type, you can then assign your R2 to a Generic OptoMMP pointer in the calling chart and then pass that pointer into the subroutine.

See How can I pass ANY IO unit to a subroutine - #5 by philip

In the post I talk about assigning to a pointer table, but I don’t think that is necessary. If you need more clear steps, let me know and I will look up that subroutine and see how I have it set up.

1 Like

Thank you Philip, that is the exact issue I am encountering, and, at least in my head, was the exact type of solution I thought might exist :wink:

Turns out, you do have to use a pointer table to get this to work. Here is how I call a subroutine that has a Generic OptoMMP Device as the parameter type:

ptIOUnit is a pointer table with length of 1
pIOUnit is a pointer to a Generic OptoMMP Device
The IO Unit (in this case UPS_AH2), can be any type of IO Unit.

Haven’t gotten around to implementing this yet, but you REALLY need that first step in there? Interesting.

Yes, PAC Control will not allow you to directly assign an R1 to a pointer for a Generic MMP (compile error in Optoscript).

There is no type checking during compiling when moving to and from a pointer table which is what allows this to work. And the runtime doesn’t care that you are assigning an R1 to a generic MMP pointer.

The type checking on Generic OptoMMP Device pointer could probably be relaxed in PAC Control - I’ve let support know about this a while back…