OpenEtherCATsociety / SOES

Simple Open Source EtherCAT Slave
Other
566 stars 247 forks source link

SDO and Mailbox help, 16 bit aligned support? #88

Open lowkin18 opened 3 years ago

lowkin18 commented 3 years ago

Just wondering if their is a 16 bit minimum data size version of SOES or if there is any plans to make one in the future?

To add onto that, I am having an issue getting SDO working from the slave side, it seems like my slave mailboxes are not working correctly.

**EDIT

I guess I might be having some confusion, does the SDO data get passed to and from the mailbox? I seem to be reading and writing mailboxes but they seem to only be of length 10 for recieving or 4 for sending.

If I write my own SOEM program that writes to the SDO it seems I can increase the mailbox length but still no SDO is getting output. Seems like I am reading erroneous data.

In twincat, the COE tab shows the device as offline, am I forgetting to run a function in SOES or is something getting mangled.


when I run slaveinfo with SDO i get this. length = 0xA address = 0x0 channel = 0x0 priority = 0x0 mbxtype = 0x3 mbxcnt = 0x1

**Note, 16 bits for each MBX MBX [3] = 0 MBX [4] = 8192 MBX [5] = 64 MBX [6] = 28

For the coeprocess call, I always seem to get MBX_error (MBXERR_INVALIDSIZE);

void ESC_coeprocess (void)
{
   _MBXh *mbh;
   _COEsdo *coesdo;
   _COEobjdesc *coeobjdesc;
   uint16_t service;
   if (ESCvar.MBXrun == 0)
   {
      return;
   }
   if (!ESCvar.xoe && (MBXcontrol[0].state == MBXstate_inclaim))
   {
      mbh = (_MBXh *) &MBX[0];
      if (mbh->mbxtype == MBXCOE)
      {
         if (etohs (mbh->length) < COE_MINIMUM_LENGTH)
         {
            MBX_error (MBXERR_INVALIDSIZE);
         }
         else
         {
            ESCvar.xoe = MBXCOE;
         }
      }
   }
nakarlsson commented 3 years ago

Currently there are no plans to support '16 bit minimum size'. At rt-labs we've not had any projects requiring that so far. If you're interested in contributing please feel free. rt-labs can support adding the 16bit min size support as a professional service project.

To answer your questions, yes SDOs are written/read to/from the mailboxes. And I think you can have multiple issues causing a faulty behavior due to what this topic is about, there are several "HW" structs that map 1:1 to Byte size fields, _MBX; being one.

lowkin18 commented 3 years ago

Does a mailbox length of 10 seem correct when running slaveinfo from master, seems odd that all the other information seems correct but I am below the COE_MININUM_LENGTH I am trying to find the problem, and I am finding the documentation on ethercats mailbox protocol for COE specifically hard to track down.

In terms of contribution, I don't really know what that entails, would I just make a pull request when I get it working with 16 bit alignment?

The project I am currently working on is just a hobby project that I am continuing from my Electrical Engineering capstone, So I don't have the budget to pay for professional support or consulting.

nakarlsson commented 3 years ago

Take a Wireshark and you'll be able to match/map the protocol(s) data for the different parts of the Frame/Mbx header/CoE header. Btw, does etohs evaluate to something else than for a little endian target?

#define htoes(x) (x)
#define htoel(x) (x)

#define etohs(x) htoes (x)
#define etohl(x) htoel (x)

Contribution: Yes, you'd need to sign a CLA "https://openethercatsociety.github.io/cla/cla_soem_soes.pdf" and provide a pull request,