[etherlab-users] New mailing list question

Graeme Foot Graeme.Foot at touchcut.com
Tue Jan 14 23:56:15 CET 2020


Hi Pierre,

Calling the master functions from the command line using popen works perfectly well.  e.g.:

popen("/usr/bin/ethercat states -a1 -p0 INIT 2>&1", "r")
popen("/usr/bin/ethercat states -a1 -p0 BOOT 2>&1", "r")

// Note: the optional password not passed in this command
popen("/usr/bin/ethercat foe_write -a1 -p0 -o \"firmwarename\" -  < /tmp/firmware 2>&1", "r")

popen("/usr/bin/ethercat states -a1 -p0 INIT 2>&1", "r")


You can use something like the following to check the current state of the device to wait until it has transitioned:

popen("/usr/bin/ethercat slaves -a1 -p0 -v 2>&1 | grep 'State:' ", "r")


I'll assume you know how to use popen and format the commands with the appropriate alias, position and firmware info.


In my case I have a Web control interface for my system that allows a firmware file to be uploaded with the above commands being called from a cgi.


Regards,
Graeme Foot.


From: etherlab-users <etherlab-users-bounces at etherlab.org> On Behalf Of Gavin Lambert
Sent: Wednesday, 15 January 2020 11:14 AM
To: Pierre Kurkdjian <pkurkdjian at gmto.org>
Cc: etherlab-users at etherlab.org
Subject: Re: [etherlab-users] New mailing list question

Please keep replies on the mailing list.

As I said, you can (as an alternative to invoking the ethercat command line app) use the same IOCTL interface that it uses internally to perform the appropriate functions.  FoE transfers can be done the same way.

Note that the ioctl/ethercat-tool based FoE transfers can only update one slave at a time, as they’re blocking APIs.  If you want to be able to update multiple slaves in parallel, the unofficial patchset (https://sourceforge.net/u/uecasm/etherlab-patches/ci/default/tree/) adds an foe_request API that can be used asynchronously, although it’s more complex to manage.

Even if you don’t want to use foe_requests, you should probably use the patchset anyway as it contains some critical bugfixes for FoE.


Gavin Lambert
Senior Software Developer


[cid:image008.png at 01D5CB96.B1064A10]
[TOMRA]<http://www.compacsort.com>[Facebook]<https://www.facebook.com/Compacsort>[Linkedin]<https://www.linkedin.com/company/compac-sorting-equipment/>[Youtube]<https://vimeo.com/compacsort>[twitter]<https://twitter.com/compacsort>[instagram]<https://www.instagram.com/compacsort/>

COMPAC SORTING EQUIPMENT LTD | 4 Henderson Pl | Onehunga | Auckland 1061 | New Zealand
Switchboard: +64 96 34 00 88 | tomra.com<http://www.tomra.com>

The information contained in this communication and any attachment is confidential and may be legally privileged. It should only be read by the person(s) to whom it is addressed. If you have received this communication in error, please notify the sender and delete the communication.

From: Pierre Kurkdjian <pkurkdjian at gmto.org<mailto:pkurkdjian at gmto.org>>
Sent: Wednesday, 15 January 2020 07:17
To: Gavin Lambert <gavin.lambert at tomra.com<mailto:gavin.lambert at tomra.com>>
Subject: Re: [EXTERNAL] RE: New mailing list question

Hello Gavin,

Thank you for your answer.
Indeed I need to go to BOOT state in order to update the slave firmware.
I need to automatize the firmware loading with a C/C++ program so I need to go to BOOT.
I think the only solution consists in calling the command line “ethercat state -p0 BOOT” by a C/C++ function.

Best,
Pierre Kurkdjian
Real-Time Software Engineer
Giant Magellan Telescope Organization


From: Gavin Lambert <gavin.lambert at tomra.com<mailto:gavin.lambert at tomra.com>>
Date: Sunday, January 12, 2020 at 2:27 PM
To: Pierre Kurkdjian <pkurkdjian at gmto.org<mailto:pkurkdjian at gmto.org>>
Subject: [EXTERNAL] RE: New mailing list question

There isn’t any API in ecrt.h for controlling the state of an individual slave device, but you can use the ioctl API that the ethercat command line tool uses to do that, if you wish.  (It only makes sense to do so when the master app is not running, or at least has not activated the PDO cycle.)

Usually it’s not necessary; the master will automatically bring devices from INIT to PREOP in all cases, and if ecrt_master_activate has been called it will bring them to OP automatically.

There’s typically no reason to explicitly request SAFEOP mode (that’s a failsafe state that a device will drop to itself if something goes wrong in OP), and there’s not much reason for a master application to bring a device to BOOT state (as that’s just for firmware reprogramming, which is rare and will require follow-up FoE commands).


Gavin Lambert
Senior Software Developer


[cid:image015.png at 01D5CB96.B1064A10]
[TOMRA]<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.compacsort.com%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040021175&sdata=0eDszIcnkHm5ad26pjNEsiTBhBMUioZoZFA6Cb9vAWo%3D&reserved=0>[Facebook]<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.facebook.com%2FCompacsort&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040031173&sdata=1Rq7fLg35mGP2jS%2B1yNJN2gtiFCdVVEzQh0%2B4qdIeBA%3D&reserved=0>[Linkedin]<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fcompany%2Fcompac-sorting-equipment%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040031173&sdata=8oqC9gF%2BpAOMtg5nATDvi%2BA4mry%2Fr9T%2BvT3IcrsNTzE%3D&reserved=0>[Youtube]<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvimeo.com%2Fcompacsort&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040041156&sdata=k9vb8wDv3nTbG73RzJB1hJwgWJu62vop%2F98FljaDqL8%3D&reserved=0>[twitter]<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Fcompacsort&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040041156&sdata=bXRsdGYBgSVy8MMpjDMlbTBBNN4UFkKW%2FDYTUsxbc4c%3D&reserved=0>[instagram]<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.instagram.com%2Fcompacsort%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040041156&sdata=UG2Y7WPg%2Fb2J1lKmViy%2FtxuRlwmoVqkY8KdntuY3hV0%3D&reserved=0>

COMPAC SORTING EQUIPMENT LTD | 4 Henderson Pl | Onehunga | Auckland 1061 | New Zealand
Switchboard: +64 96 34 00 88 | tomra.com<https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.tomra.com&data=02%7C01%7Cgavin.lambert%40tomra.com%7C4b3b15b54f044eebdaa708d7991de79b%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C637146226040051153&sdata=dejDu98WBRDsRvE7srhHFlbHSHa1daBb%2BBEsuaasNJw%3D&reserved=0>

The information contained in this communication and any attachment is confidential and may be legally privileged. It should only be read by the person(s) to whom it is addressed. If you have received this communication in error, please notify the sender and delete the communication.

From: Pierre Kurkdjian
Sent: Saturday, 11 January 2020 08:50
To: etherlab-users at etherlab.org<mailto:etherlab-users at etherlab.org>
Subject: [etherlab-users] New mailing list question

Hello Etherlab community,

I would like to implement the entire ethercat state machine in C/C++.
Etherlab ethercat allows the users to select the ethercat state of each ethercat slave with command line, like that:

ethercat states -p0 INIT

ethercat states -p0 SAFEOP

ethercat states -p0 OP

…
My question is: Is there a way to do the same thing using the C functions?
It’s possible to go to preop by reserving a master (calling ecrt_request_master() ).
It’s possible to go to op by activating the master (calling ecrt_request_master() ).
But is there a way to go to safeop and to boot ?

Thank you for your time.

Best,
Pierre Kurkdjian
Real-Time Software Engineer
Giant Magellan Telescope Organization
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0004.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image008.png
Type: image/png
Size: 11438 bytes
Desc: image008.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0070.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image009.png
Type: image/png
Size: 1629 bytes
Desc: image009.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0071.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image010.png
Type: image/png
Size: 1750 bytes
Desc: image010.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0072.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image011.png
Type: image/png
Size: 1855 bytes
Desc: image011.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0073.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image012.png
Type: image/png
Size: 1970 bytes
Desc: image012.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0074.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image013.png
Type: image/png
Size: 20278 bytes
Desc: image013.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0075.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image014.png
Type: image/png
Size: 1506 bytes
Desc: image014.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0076.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image015.png
Type: image/png
Size: 11439 bytes
Desc: image015.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0077.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image016.png
Type: image/png
Size: 1630 bytes
Desc: image016.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0078.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image017.png
Type: image/png
Size: 1751 bytes
Desc: image017.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0079.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image018.png
Type: image/png
Size: 1856 bytes
Desc: image018.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0080.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image019.png
Type: image/png
Size: 1971 bytes
Desc: image019.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0081.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image020.png
Type: image/png
Size: 20279 bytes
Desc: image020.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0082.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image021.png
Type: image/png
Size: 1507 bytes
Desc: image021.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20200114/f210f9f0/attachment-0083.png>


More information about the Etherlab-users mailing list