Delta Tau Forums
Execute cmd using a string in ecat[0].IOBuffer[] - Printable Version

+- Delta Tau Forums (http://forums.deltatau.com)
+-- Forum: Delta Tau Data Systems (http://forums.deltatau.com/forumdisplay.php?fid=1)
+--- Forum: Power PMAC (http://forums.deltatau.com/forumdisplay.php?fid=2)
+--- Thread: Execute cmd using a string in ecat[0].IOBuffer[] (/showthread.php?tid=2845)



Execute cmd using a string in ecat[0].IOBuffer[] - rvanderbijl - 03-04-2019

Hi all,

I am trying to get some, perhaps odd, functionality implemented on the PMAC. I have a string that is received through EtherCAT, and deposited in ECAT[0].IOBuffer[] at a certain offset. I would like to be able to copy that string and somehow pass it to the cmd command. I'm sure I can do this through some C++ code, but I'm trying to avoid that.

It looks like any string manipulation (strcpy/etc) is only using the Sys.CData[] region of memory. I haven't been able to specify the source to be in the ECAT[0].IOBuffer region.

I can certainly write a loop that transfers the bytes from the IOBuffer to CData one by one, but that seems rather inefficient...

Any suggestions?


RE: Execute cmd using a string in ecat[0].IOBuffer[] - curtwilson - 03-05-2019

I think you have identified the best method for doing what you need. Hopefully you can embed the transfer to the user buffer in a Script subprogram so the details are then transparent to your application.


RE: Execute cmd using a string in ecat[0].IOBuffer[] - rvanderbijl - 03-05-2019

(03-05-2019, 12:20 PM)curtwilson Wrote: I think you have identified the best method for doing what you need. Hopefully you can embed the transfer to the user buffer in a Script subprogram so the details are then transparent to your application.

Thanks for your reply Curt. I was hoping there was some way to point cmd "%s",x directly to ECAT[0].IOBuffer[x], or a way to use memcpy/strcpy but I guess there is not.

Thanks for confirming that, and yes, this will be wrapped into a script with monitoring whether or not the command executed and if there were errors.

Incidentally, we're going to be using an EL6695 Master-Master module from Beckhoff to talk to the PMAC in this way (from our other EtherCAT master), rather than using TCP/IP (and gpascii). We have a few variables that need to be transferred in more of a real-time fashion. But for the occasional oddball command, this string buffer seemed like a possible way to tackle that without having to create a custom command structure.


RE: Execute cmd using a string in ecat[0].IOBuffer[] - rvanderbijl - 04-15-2019

Curt,

Following up on this question -- I have gotten it to work fine, however, the speed at which the (even plc0) script executes is a bit too slow for what I'm trying to do. The problem is mostly in moving data around. So I'm porting my code to C.
I wasn't able to find anything on this in the documentation -- but is there any way to send a string to the PMAC parser from C? (like the "cmd" command from script)

Thanks!


RE: Execute cmd using a string in ecat[0].IOBuffer[] - steve.milici - 04-15-2019

The C-API for background C-programs has the “Command()” and “GetResponse()” functions:

int Command (char * pinstr)
Sends a command to the Pmac Command Processor. The input string is converted from symbolic to PMAC compatible commands and variables.
Parameters:
*pinstr - ptr to PMAC input string
Returns:
0 == OK, - == error number

int GetResponse (char * pinstr, char * poutstr, size_t outlen, unsigned char EchoMode)
Performs a string send with an expected return from the Pmac Command Processor. The input string must have PMAC compatible commands Note: Doesn't handle "gpascii" commands like "$$$" or "reboot".
Parameters:
*pinstr - ptr to input string
outlen - max length of output string
EchoMode - PMAC "echo" parameter which determines the format of the response
*poutstr - ptr to output string
Returns:
0 == OK, - == error number

There are many other function available like “GetPmacStatus()” and “GetPmacVar()” to name a few.

See the IDE “Help” under the “PowerPMACCLanguageManual”. If your version of the IDE does not have this help add-in (vs 3.x and vs 4.x) you can install it manually here:
"ftp://support.deltatau.com/DT-USA/milici/PPMAC%20IDE/Help%20Files/"


RE: Execute cmd using a string in ecat[0].IOBuffer[] - rvanderbijl - 04-15-2019

Thanks Steve!

With the Command() function, when it returns, can I assume the command processor has completed the command? Or should I use GetResponse() for that? In my case I'm not interested in the response to the commands, just that they have been executed.


RE: Execute cmd using a string in ecat[0].IOBuffer[] - steve.milici - 04-15-2019

Yes, that is the case.