mbuesch / pyprofibus

PROFIBUS-DP stack

Home Page:https://bues.ch/a/profibus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"input byte, "output byte" confusion

Sigma1912 opened this issue · comments

We have quickly touched on this in my earlier issues. I've had another look at this:

; The number of output bytes this slave transmits to the
; master in Data_Exchange.
; This usually depends on the modules plugged into the slave.
output_size=2

; The number of input bytes this slave expects to receive
; in Data_Exchange.
; This usually depends on the modules plugged into the slave.
input_size=0

Still seems wrong to me. My Festo Valve block expects 2 bytes FROM the master and transmits 0 bytes TO the master. So if the above is defined as viewed from the slave then "output_size" should be "0" and "input_size" should be "2". If it's defined as viewed from the master then the comments should be swapped.

These two options reside in the [SLAVE_x] section(s) of the configuration.
All options in these sections configure the slave.
Therefore the terms output and input are to be interpreted from the slave's perspective. Just like the comment suggests.
That means your values are swapped.

Swapping the values does not work because then the component doesn't create the correct number/direction for the halpins.

In my opinion the information the slave transmits to the master needs to be put into hal-pins of direction OUT (ie. "profibus.slave.8.input.bit.x.x")
information the slave recieves from the master needs to come from hal-pins of direction IN (ie. profibus.slave.8.output.bit.x.x)

To illustrate my point I have configured my input-bytes and output-bytes as posted below. With this I would expect to see 4x8 halpins of direction OUT to make the slaves response data (4 bytes) available in the HAL environment and 2x8 halpins of direction IN for the data that is to be sent from the master (2 bytes):

; The number of output bytes this slave transmits to the
; master in Data_Exchange.
; This usually depends on the modules plugged into the slave.
output_size=4

; The number of input bytes this slave expects to receive
; in Data_Exchange.
; This usually depends on the modules plugged into the slave.
input_size=2

However, this creates the exact opposite:
4 x 8 halpins "profibus.slave.8.output.bit.x.x" with hal-direction IN
2 x 8 halpins "profibus.slave.8.input.bit.x.x" with hal-direction OUT

Which is wrong since now we have too many pins with direction IN and not enough with direction OUT
Since your component embeds the slave in HAL we need IN pins for "input_size" (data sent to the slave) and OUT pins for "output_size" (data received from the slave).

I hope this makes at least somewhat sense.

Screenshot from 2021-10-14 08-07-24

Yes, the LinuxCNC HAL component might be buggy here.
That is one of the least tested and least used parts of pyprofibus.

One could also argue that the input/output HAL pin naming is swapped. It doesn't match the configuration's understanding of inputs and outputs.

Absolutely, I think it would make more sense to create the halpins "profibus.slave.n.output.x.y.z" with hal-direction OUT
halpins "profibus.slave.n.input.x.y.z" with hal-direction IN.

I've tried to change profibus-linuxcnc-hal accordingly but I get errors.

The change 26d6696 swaps the HAL's interpretation of input and output.
It's necessary to swap the input/output naming in the HAL configuration.

The change has been integrated in the pyprofibus release 1.11.
Thanks for your report!