Skip to content

Trouble accessing input bits #68

Open
@BennyBread

Description

@BennyBread

First off all thanks for the great library. I managed it to make it runnable.
But now I have trouble accessing my inputs and outputs through the memorymapping.

I use an hilscher NIC RE 50 module which has both an input area and an output area.
The inputs have an offset address of 1000, the outputs 2000

Lets say I want to read From the outputs (sdoindex 2000) Byte no. 8 Bit no. 2.

How to do this?

In the SlavePdos I can see that the 6th pdo is the start of the outputs so I assume this has address 2000.
Now I try to get the correct offset:

const int outputPdoIndex = 6;  <== first Output
const int channel = 8;
var bitOffset= SlavePdos[outputPdoIndex].Variables[channel].BitOffset;
var channel = MemoryMappingOutputs[0] & (1 << bitOffset);
var value = (byte)BitConverter.ToChar(channel.ToByteArray(), 0);

But the value is always false no matter what byte and bit offset I ask for.

I 've seen that in soemwrapper there is a function ecx_SDOread of which the parameter sdoIndex is the addess to read.

when using ethercat-explorer (https://sourceforge.net/p/ethercat-explorer/svn/HEAD/tree/)
which uses also semwrapper but oviously a different version? I can query address 2000 and get a pretty long byte array in which some bytes do have values. This code is calling ecx_sdoread as well...

So. how can I achieve to read some bool or short from an defined offset??

Any help highly appreciated!

Regards, Benny

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions