[etherlab-users] Userspace application.

Gavin Lambert gavin.lambert at tomra.com
Thu Feb 14 04:00:56 CET 2019


You have to write a little state machine (or budget equivalent using flags), to keep track of which step in the process you’re up to.

I hope you’re not confusing register requests with process data.  Process data can be read and written in a single cycle.  Register requests (and other request types) require multiple cycles.


Gavin Lambert
Senior Software Developer

[cid:logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png]
[cid:compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png]<http://www.compacsort.com> [cid:facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png] <https://www.facebook.com/Compacsort>  [cid:linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png] <https://www.linkedin.com/company/compac-sorting-equipment/>  [cid:youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png] <https://vimeo.com/compacsort>  [cid:twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png] <https://twitter.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: Shiva V M C <shivamachnalle at gmail.com>
Sent: Thursday, 14 February 2019 15:52
To: Gavin Lambert <gavin.lambert at tomra.com>
Subject: Re: [etherlab-users] Userspace application.

Hi Gavin
Can you please help me with a mentioned set of statements in a flow for writing value  to a register and then reading again from the same register.

Thanks in advance

On Thu, 14 Feb, 2019, 3:50 AM Gavin Lambert <gavin.lambert at tomra.com<mailto:gavin.lambert at tomra.com> wrote:
That’s not how you do register requests.

For a write request, you first call ecrt_reg_request_data() to get a pointer and then write the data to be written into that buffer.  Then you call ecrt_reg_request_write() once to start the request.  The request occurs asynchronously in the background and you have to call ecrt_reg_request_state() once per cycle to tell when it is completed.  You must not try to start another read or write or alter the data in the write buffer until after the request has completed (with success or failure).

Reads are similar; you call ecrt_reg_request_read() once to start the request, then ecrt_reg_request_state() once per cycle until it reports success (or failure) and only then read the resulting data out of the ecrt_reg_request_data() buffer.

Both operations may take an arbitrary number of cycles to complete, since they can be queued behind other requests.

You can start a read and write in the same cycle but only on separate request objects, and they will get queued anyway so there’s not much point.  You absolutely should not try to sleep in the cyclic loop – the only sleep allowed in there is the “main” sleep to wait for the next cycle.


Gavin Lambert
Senior Software Developer


[cid:image001.png at 01D4C47E.7406C0B0]
[cid:compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png]<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.compacsort.com&data=02%7C01%7Cgavin.lambert%40tomra.com%7C8f85145cbfbc4bfc2e6808d692277b9c%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C636857095619216153&sdata=ZGYuhxT9VvGN%2B3koc%2F9s9qGia93yeagah5HAUhMj8YI%3D&reserved=0>[cid:facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png]<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.facebook.com%2FCompacsort&data=02%7C01%7Cgavin.lambert%40tomra.com%7C8f85145cbfbc4bfc2e6808d692277b9c%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C636857095619226161&sdata=x8lovsaT3Axiqp8GmJZE87VzSNmThwzkobGG79%2FBV1c%3D&reserved=0>[cid:linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png]<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fcompany%2Fcompac-sorting-equipment%2F&data=02%7C01%7Cgavin.lambert%40tomra.com%7C8f85145cbfbc4bfc2e6808d692277b9c%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C636857095619236170&sdata=IDxfsailKdPtUKGPYsbLWFYnHhxcLio3crkvSicDL4s%3D&reserved=0>[cid:youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png]<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvimeo.com%2Fcompacsort&data=02%7C01%7Cgavin.lambert%40tomra.com%7C8f85145cbfbc4bfc2e6808d692277b9c%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C636857095619236170&sdata=vzMJLRS2EVJk3nEVtskdlnXP5JC7dScRIJFrjuMgoac%3D&reserved=0>[cid:twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png]<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Fcompacsort&data=02%7C01%7Cgavin.lambert%40tomra.com%7C8f85145cbfbc4bfc2e6808d692277b9c%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C636857095619246175&sdata=phq1lRRrWL4nttfRqMia3CKf6ZVySQEuXd7K%2FQ%2FFeTM%3D&reserved=0>

COMPAC SORTING EQUIPMENT LTD | 4 Henderson Pl | Onehunga | Auckland 1061 | New Zealand
Switchboard: +64 96 34 00 88 | tomra.com<https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.tomra.com&data=02%7C01%7Cgavin.lambert%40tomra.com%7C8f85145cbfbc4bfc2e6808d692277b9c%7C4308d118edd143008a37cfeba8ad5898%7C0%7C0%7C636857095619246175&sdata=4krVOgSp0ryc8z1ucdOdlMBwSIArkdcqU%2FLt4EA%2Ffs8%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: etherlab-users <etherlab-users-bounces at etherlab.org<mailto:etherlab-users-bounces at etherlab.org>> On Behalf Of Shiva V M C
Sent: Thursday, 14 February 2019 00:59
To: etherlab-users at etherlab.org<mailto:etherlab-users at etherlab.org>
Subject: [etherlab-users] Userspace application.

Hi all,
I have done with my user space application and I m able to run the application too.
Now I want to perform 2 exercise i.e.,
1.ecrt_reg_request_write();
2.ecrt_reg_request_read();
I m able to read the particular register,but couldn't able to write on any of the register.
So,could any one help me whats happening?.

This is my code snippet.
 #define DigInSlavePos  0, 0
#define Beckhoff_EL1240 0x00000002, 0x02312862
I m doing this before activating master,

if(!(sc_dig_in = ecrt_master_slave_config(master,DigInSlavePos,Beckhoff_EL1240)))
{
fprintf(stderr, "Failed to configure BeckHoff  Salve.\n");
        return -1;
 }
regis=ecrt_slave_config_create_reg_request(sc_dig_in,127);

Then called cyclic_task as below
void cyclic_task()
  {
  ec_reg_request *regis;
  ecrt_master_receive(master);
   ecrt_domain_process(domain1);
   check_domain1_state(); //optional
   if (counter) counter--;
   else
    {   counter = FREQUENCY;
         blink = !blink;
         check_master_state(); //optional
         check_slave_config_states(); //optional;
         ecrt_reg_request_write(regis,0xf80, 64);
         sleep(1);
         ecrt_reg_request_read(regis,0xf80, 64);
        // send process data
         ecrt_domain_queue(domain1);
         ecrt_master_send(master);
      }
}


--
Thanks & Regards
Shiva V M C
09880153358
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0004.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 11438 bytes
Desc: image001.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0035.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png
Type: image/png
Size: 11438 bytes
Desc: logo_compac_5dcf97ef-52f5-498c-8b9b-728410ddffaf.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0036.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png
Type: image/png
Size: 1629 bytes
Desc: compacicon_82e8a8c7-154a-4a32-9720-a5badb6258e0.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0037.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png
Type: image/png
Size: 1750 bytes
Desc: facebook_fa85b924-53b9-45cc-8162-0564f64ec3a3.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0038.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png
Type: image/png
Size: 1855 bytes
Desc: linkedin_4ec016ad-84fa-443c-85a3-b9615a4ccef8.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0039.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png
Type: image/png
Size: 1970 bytes
Desc: youtube_32142163-fc27-4aed-b14d-e8a377f98a6d.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0040.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png
Type: image/png
Size: 20278 bytes
Desc: twitter_d89338d8-98c8-4b65-9a9e-7b1333160b0d.png
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20190214/40e4dbf0/attachment-0041.png>


More information about the Etherlab-users mailing list