tecki / ebpfcat

A Python-base EBPF code generator
GNU General Public License v2.0
16 stars 5 forks source link

How to use SyncManager(...) ? #9

Open jinyistudio534 opened 5 months ago

jinyistudio534 commented 5 months ago

Hi, Sorry, can you give me a sample program to teach me how to use SyncManager ?

tecki commented 4 months ago

I guess that you actually want to know how to use a PacketDesc. That is declared with something like

myData = PacketDesc(SyncManager.IN, 12, "H")

meaning that at position 12 in the input sync manager, i.e. the one to get data from the slave to the master, there is an unsigned 16 bit integer ("H"), that one can read.

myBit = PacketDesc(SyncManager.OUT, 24, 5)

means at byte position 24, bit number 5 can be written to the slave.

jinyistudio534 commented 4 months ago

Hi,

  1. Is there no need to declare before using SyncManager.IN?
  2. Can you tell me what the functionality of SyncManager is and when can I use it? *_class ebpfcat.ethercat.SyncManager(value, names=None, values, module=None, qualname=None, type=None, start=1, boundary=None)_**
tecki commented 4 months ago

Well, this is an enum, with two possible values: IN and OUT. Unfortunately, sphinx always auto-generated this weird documentation, I still have to figure out how to stop it from doing so.

jinyistudio534 commented 4 months ago

I guess that you actually want to know how to use a PacketDesc. That is declared with something like

myData = PacketDesc(SyncManager.IN, 12, "H")

meaning that at position 12 in the input sync manager, i.e. the one to get data from the slave to the master, there is an unsigned 16 bit integer ("H"), that one can read.

myBit = PacketDesc(SyncManager.OUT, 24, 5)

means at byte position 24, bit number 5 can be written to the slave.

👉👉👉_Use PacketDesc() to read or write 32 bytes at a time. How to input format ?_

tecki commented 4 months ago

I am not sure what you try to do. You could try to use "32s", that should work at least with the normal (not fast) ethercat. In Fast ethercat mode, this is not possible as EBPF does not allow to read or write 32 bytes at a time.