MAC Address of PAC Controller

Hi,

We can use PAC Control to get the IP address of the PAC controller.
How to get the its MAC address in PAC Control?

Hi Edmund,

Short answer: Use the I/O Unit ā€“ Memory Map Commands.

Longer answer: (Including pictures, sample code, and OptoMary commentary.) :cool:

Let me answer a more general question (How do I read/write values accessible via PAC Manager in my PAC Control strategy?), using this particular question as the example.

As you may know, many of the commands in PAC Control access parts of the memory map for you. For example, it sounds like you might already be using the built-in command: Get Control Engine Address.

That command does the equivalent of reading the IP address from the mem map (address: F030 0038 as documented in form 1465), then converts it to a string, like the command: Convert Integer 32 to IP Address String does.

In particular for this case, I can see my PACā€™s MAC address here in the ā€œStatus Readā€ section of PAC Managerā€™s Inspect tool. (This even works with SoftPAC, the Ethernet info you see below is for this PC.)


If you donā€™t already have an I/O Unit configured for the PAC you want to read (for example, if youā€™re using SoftPAC or a PAC-S series you might not have an I/O Unit since you donā€™t have any I/O on that unit), configure one something like this:


Then you can use commands like this:

The MAC Address you asked about is a little unusual in that itā€™s 6 bytes vs. 4 or 8 like most of our data types, so that INTEGER 64 value read above, which I called nnMACplutTwoBytes, has a couple of bytes extra that are not part of the MAC address. (Our variable has 64 bits = 8 bits per byte x 8 bytes). How you deal with those extra 2 bytes of data will depend on what you want to do with that address.

Assuming here that you just want to display it somewhere as a nice string which looks like what you see in PAC Manager, Iā€™d do something like this:


Hereā€™s the text in case you want to copy/paste:

// this yields a string with a couple extra bytes, like this: 6C626DE9A4FD0AC0 (16 characters)
NumberToFormattedHexString( nnMACplusTwoBytes, 16, sMACAddressAsString );


// Get each byte in the MAC Address as a 2-characters string in the table stMACbytes
for nMACByteIndex = 0 to 5 step 1

  GetSubstring( sMACAddressAsString, nMACByteIndex * 2, 2, stMACbytes[nMACByteIndex] );

next

// Build the human-readable string with a dash between each byte

sMACAddressAsString = ""; // we're re-using the same string here, clear it out first

for nMACByteIndex = 0 to 4 step 1

  sMACAddressAsString = sMACAddressAsString  + stMACbytes[nMACByteIndex] + "-";

next
sMACAddressAsString = sMACAddressAsString  + stMACbytes[5];


Which gets me this:

I hope that helps! By the way, this post on how to change your IP Address (from within your strategy) might be of interest too: http://www.opto22.com/community/showthread.php?t=472&page=1

-OptoMary

Edmund and all,

I used the code sample provided by Mary to build a ā€˜diagnosticā€™ chart for my controller.
The goal was to show some information about the controller in my groov Project.

Here is a screen shot of some of that information.


In a nut shell, you can get strings and ints and stuff (tech term there) from the mem map location and store them in the controller.
Once in the controller, you can do pretty much anything with them, from Pac Display, to groov, to email alarms and reports and stuff.

Cheers,

Ben.

1 Like

GIMPY!!!
I donā€™t know but Iā€™ll look into it.

Hi OptoMary & Ben,

Thanks for your detail information.

We can use the MAC address to protect our PAC Control code.

Edmund