phw_sock_raw_mmaped not working in 0.6
Hi Robert,
I tested the hw refactoring. RAW works fine, but RAWMMAPED seems to have a bug.
First, I think a hw_open call is missing in https://github.com/robert-burger/libethercat/blob/e0be7c856f12db2e3d3c1fcfaa47eb01c0a495c8/src/hw_sock_raw_mmaped.c#L117-L119
But fixing this (https://github.com/marcfir/libethercat/tree/fix/rawmmaped) leads to a timeout. Looking with tcpdump shows that frames are outgoing. So I think the problem is in the recv function.
2024-09-02T08:59:18.832Z INFO [libethercat_rs::base_types] Heap allocated for the ethercat master struct 68092064 bytes
2024-09-02T08:59:18.832Z INFO [libethercat_rs::base_types] Heap allocated for hw_sock_raw_mmaped_t 13208 bytes
2024-09-02T08:59:18.832Z INFO [libethercat_rs] HW_OPEN : got page size 4096 bytes
2024-09-02T08:59:18.889Z INFO [libethercat_rs] HW_OPEN : binding raw socket to enp5s0
2024-09-02T08:59:18.889Z INFO [libethercat_rs] HW_OPEN : got mtu size 1500
2024-09-02T08:59:18.913Z INFO [libethercat_rs] HW_OPEN : Opend phw with size 13208
2024-09-02T08:59:18.939Z INFO [libethercat_rs] ASYNC_LOOP : async loop thread running
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : libethercat version : 0.5.1
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_SLAVES : 256
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_GROUPS : 8
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_PDLEN : 3036
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_MBX_ENTRIES : 16
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_INIT_CMD_DATA : 2048
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_SLAVE_FMMU : 8
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_SLAVE_SM : 8
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_DATAGRAMS : 100
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_EEPROM_CAT_SM : 8
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_EEPROM_CAT_FMMU : 8
2024-09-02T08:59:18.940Z INFO [libethercat_rs] MASTER_OPEN : MAX_EEPROM_CAT_PDO : 128
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_EEPROM_CAT_PDO_ENTRIES : 32
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_EEPROM_CAT_STRINGS : 128
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_EEPROM_CAT_DC : 8
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_STRING_LEN : 128
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_DATA : 4096
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_DS402_SUBDEVS : 4
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_COE_EMERGENCIES : 10
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : MAX_COE_EMERGENCY_MSG_LEN : 32
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_OPEN : Master struct needs 68092064 bytes
2024-09-02T08:59:18.941Z INFO [libethercat_rs] MASTER_SET_STATE : switching from EC_STATE_UNKNOWN to EC_STATE_INIT
2024-09-02T08:59:19.041Z ERROR [libethercat_rs] MASTER_TRANSCEIVE : timeout on cmd 0x8, adr 0x1200000
2024-09-02T08:59:19.141Z ERROR [libethercat_rs] MASTER_TRANSCEIVE : timeout on cmd 0x7, adr 0x0
2024-09-02T08:59:19.141Z ERROR [libethercat_rs] MASTER_SCAN : broadcast read of slave types failed with 65600
thread 'main' panicked at libethercat-rs/examples/main.rs:37:43:
called `Result::unwrap()` on an `Err` value: StateNotReachable
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on enp5s0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
09:05:20.096764 00:30:64:0f:83:35 (oui Unknown) > Broadcast, ethertype Unknown (0x88a4), length 30:
0x0000: 1e10 0800 0000 2001 0200 0000 1100 0000 ................
09:05:20.096800 02:30:64:0f:83:35 (oui Unknown) > Broadcast, ethertype Unknown (0x88a4), length 60:
0x0000: 1e10 0800 0800 2001 0200 0000 1100 0800 ................
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
09:05:20.197009 00:30:64:0f:83:35 (oui Unknown) > Broadcast, ethertype Unknown (0x88a4), length 30:
0x0000: 1e10 0701 0000 0000 0200 0000 0000 0000 ................
09:05:20.197052 02:30:64:0f:83:35 (oui Unknown) > Broadcast, ethertype Unknown (0x88a4), length 60:
0x0000: 1e10 0701 0800 0000 0200 0000 1301 0800 ................
0x0010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0020: 0000 0000 0000 0000 0000 0000 0000 ..............
yes, you're right. the creation of a receive thread is missing in the sock_raw_mmaped hw layer. i'll re-add this.
note: the open function pointer does not need to be addded to the hw_common struct as it needs to be called in prior to ec_open by the user. it does also take an arbitrary number of arguments depending on the needs of the hw layer so there's no way for libethercat call this...
should be fixed with 9108db1