...
Quick solution: In TCPServer.c located under <driver_version>examples/cifXTCPServer/, line 56 replace pthread_mutex_t* g_ptMutex to e.g static pthread_mutex_t* s_ptMutex and replace g_ptMutex to s_ptMutex.
Run Python script example
Download pycifx here.
Extract the sources from the zip-file and go in to pycifx.
Connect a netX90 based device to the Raspberry Pi
netSHIELD90 and Raspberry Pi pinout
Note |
---|
Make sure to configure your netx90 based device via netX Studio. |
Run cifxspisample. You should get a similar output
Code Block | ||||
---|---|---|---|---|
| ||||
pi@raspberrypi:~ $ cd pycifx/
pi@raspberrypi:~/pycifx $ |
run main.py
Code Block | ||||
---|---|---|---|---|
| ||||
pi@raspberrypi:~/pycifx/V2.1.1.0/V2.1.1.0/examples/build $ sudo python3 main.py |
Connect a netX90 based device to the Raspberry Pi
netSHIELD90 and Raspberry Pi pinout
Note |
---|
Make sure to configure your netx90 based device via netX Studio. |
...
./cifxsample
---------- Display Driver Version ----------
Driver Version: LinuxCIFXDrv V2.1.0.0, based on cifX Toolkit 2.6.0.0
State = 0x00000000
----------------------------------------------------
---------- Board/Channel enumeration demo ----------
Found Board cifX0
DeviceNumber : 7833000
SerialNumber : 20000
Board ID : 0
System Error : 0x00000000
Channels : 2
DPM Size : 65536
- Channel 0:
Firmware : PROFINET IO Device
Version : 5.4.0 build 0
Date : 10/18/2021
Device Nr. : 7833000
Serial Nr. : 20000
netX Flags : 0x00000038
Host Flags : 0x00000038
Host COS : 0x00000000
Device COS : 0x00000001
- Channel 1:
Firmware : Network Services
Version : 1.0.0 build 0
Date : 10/18/2021
Device Nr. : 7833000
Serial Nr. : 20000
netX Flags : 0x00000038
Host Flags : 0x00000038
Host COS : 0x00000000
Device COS : 0x00000001
State = 0x00000000
----------------------------------------------------
---------- System Device handling demo ----------
System Channel Info Block:
==========================
DPM Cookie : netX
DPM Size : 32768
Device Number : 7833000
Serial Number : 20000
HW Options : 0x0080 0x0080 0x0000 0x0000
Manufacturer : 1
Production Date : 4395
Device Class : 60
HW Revision : 3
HW Compatibility : 0
License Flags 1 : 0x00000000
License Flags 2 : 0x00000003
LicenseID : 0x0000
LicenseFlags : 0x0000
==========================
System Information:
===================
System Error : 0x00000000
DPM Size : 32768
Mailbox size : 124
Device Number : 7833000
Serial Number : 20000
Open Count : 1
===================
System Control Block:
=====================
Command COS : 0x00000000
System Control : 0x00000000
=====================
Waiting 2s to let cifX card calculate CPU load!
System Status Block:
====================
System COS : 0x00000000
System Status : 0x22000001
System Error : 0x00000000
Time since start : 20899
CPU Load [%] : 4.00
====================
Trying to read Security Eeprom:
===============================
System Mailbox State: MaxSend = 16, Pending Receive = 0
Send Packet (Read Crypto Flash Zone 1):
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00001EBC
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000004 Rout : 0x00000000
Data:
01 00 00 00
System Mailbox State: MaxSend = 16, Pending Receive = 1
Received Packet (Read Crypto Flash Zone 1):
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00001EBD
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
System Mailbox State: MaxSend = 16, Pending Receive = 0
===============================
State = 0x00000000
----------------------------------------------------
---------- Communication Channel demo ----------
Communication Channel Info:
Device Number : 7833000
Serial Number : 20000
Firmware : PROFINET IO Device
FW Version : 5.4.0 build 0
FW Date : 10/18/2021
Mailbox Size : 1596
Start put/get packet Demo!
Channel Mailbox State: MaxSend = 1, Pending Receive = 0
Send Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0x00000000
DestID : 0x00000000 Cmd : 0x00000000
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
Received Packet:
Dest : 0x00000000 ID : 0x00000000
Src : 0x00000000 Sta : 0xC0000004
DestID : 0x00000000 Cmd : 0x00000001
SrcID : 0x00000000 Ext : 0x00000000
Len : 0x00000000 Rout : 0x00000000
Data:
Start read/write IO-Data!
Error setting Bus state lRet = 0x800C0012!
--- Read / Write Block Information ---
Read CONTROL Block
00 00 00 00
Write CONTROL Block
Read COMMON Status Block
01 00 00 00
Write COMMON Status Block
Error writing to common status block. lRet = 0x800A0006
Read EXTENDED Status Block
00 00 00 00
Write EXTENDED Status Block
Error writing to extended status block. lRet = 0x800A0006
--- Event handling demo ---
Sync-handshake mode: 0x02 (host controlled)
Error: 0x800A001A, <Interrupt is disabled>
--- Set Bus / Host State Demo ---
Set CIFX_HOST_STATE_READY!
CIFX_HOST_STATE_READ, state 1 !
Error CIFX_BUS_STATE_ON, state 0, error 0x800C0012 !
CIFX_BUS_STATE_OFF, state 0 !
Set CIFX_HOST_STATE_NOT_READY!
CIFX_HOST_STATE_READ, state 0 !
State = 0x00000000
----------------------------------------------------
pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $ |
Run Python script example
If you do not want to compile the examples. You can run our python script to verify if the driver and the device work.
Download pycifx here.
Extract the sources from the zip-file and go in to pycifx folder.
Code Block | |||||||
---|---|---|---|---|---|---|---|
| pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/build $ sudo ./cifxsample
---------- Display Driver Version ----------
Driver Version: LinuxCIFXDrv V2.1.0.0, based on cifX Toolkit 2.6.0.0
State = 0x00000000
| ||||||
pi@raspberrypi:~ $ cd pycifx/
pi@raspberrypi:~/pycifx $ |
run main.py and you should get a similar output
Code Block | ||||
---|---|---|---|---|
| ||||
pi@raspberrypi:~/pycifx $ sudo python3 main.py ------------------------------------------ Display Driver Version ---------- Driver Version: LinuxCIFXDrv V2.1.0.0, based on cifX Toolkit 2.6.0.0 ---------- Board/Channel enumeration demo ---------- Found Board cifX0 Alias : DeviceNumber : 7833000 SerialNumber : 20000 Board ID : 0 System Error : 0x000000000 Channels : 2 DPM Size : 65536 - Channel 0: Firmware : PROFINET IO Device Version : 5.4.0 build 0 Date : 10/18/2021 Device Nr. : 7833000 Serial Nr. : 20000 netX Flags : 0x00000038 Host Flags : 0x00000038 Host COS : 0x000000000x00000001 Device COS : 0x00000001 - Channel 1: Firmware : Network Services Version : 1.0.0 build 0 Date : 10/18/2021 Device Nr. : 7833000 Serial Nr. : 20000 netX Flags : 0x00000038 Host Flags : 0x00000038 Host COS : 0x00000000 Device COS : 0x00000001 State =0x00000001 0x00000000 ---------------------------------------------------- ---------- System Device handling demo ---------- System Channel Info Block: ========================== DPM Cookie : netX DPM Size : 32768 Device Number : 7833000 Serial Number : 20000 HW Options : 0x008020000 0x0080Manufacturer 0x0000 0x0000 Manufacturer : 1 Production Date : 4395 Device Class : 60 HW Revision : 3 HW Compatibility : 0 License Flags 1 : 0x00000000 License Flags 2 : 0x00000003 LicenseID : 0x0000 LicenseFlags : 0x0000 ========================== System Informationinformation: =================== System Error : 0x00000000 DPM Size : 32768 Mailbox size : 124 Device Number : 7833000 Serial Number : 20000 Open Count : 1 =================== System Control Block: ===================== Command COS : 0x00000000 System Control : 0x00000000 ===================== Waiting 2s to let cifX card calculate CPU load! System Status Block: ==================== System COS : 0x00000000 System Status : 0x22000001 System Error : 0x00000000 Time since start : 2089921921 CPU Load [%] : 4.00 ==================== Trying to read Security Eeprom: =======4.00 ======================== System Mailbox State: MaxSend = 16, Pending Receive = 0 Send Packet (Read Crypto Flash Zone 1): Dest : 0x00000000 ID : 0x00000000 Src : 0x00000000 Sta : 0x00000000 DestID : 0x00000000 Cmd : 0x00001EBC0x00000000 SrcID : 0x00000000 Ext : 0x00000000 Len : 0x000000040x00000000 Rout : 0x00000000 Data: 01 00 00 00 System Mailbox State: MaxSend = 16, Pending Receive = 1 Received Packet (Read Crypto Flash Zone 1): Dest : 0x00000000 ID : 0x00000000 Src : 0x00000000 Sta : 0xC0000004 DestID : 0x00000000 Cmd : 0x00001EBD0x00000001 SrcID : 0x00000000 Ext : 0x00000000 Len : 0x00000000 Rout : 0x00000000 Data: System Mailbox State: MaxSend = 16, Pending Receive = 0 =============================== State = 0x00000000 --------------------> -------------------------------- ---------- Communication Channel demo ---------- Communication Channel Info: =========================== Device Number : 7833000 Serial Number : 20000 Firmware : PROFINET IO Device FW Version : 5.4.0 build 0 FW Date : 10/18/2021 Mailbox Size =========================== Mailbox Size : 1596 Start put/get packet Demo! Channel Mailbox State: MaxSend = 1, Pending Receive = 0 Send Packet: Dest : 0x00000000 ID : 0x00000000 Src : 0x00000000 Sta : 0x00000000 DestID : 0x00000000 Cmd : 0x00000000 SrcID : 0x00000000 Ext : 0x00000000 Len : 0x00000000 Rout : 0x00000000 Data: ReceivedReceive Packet: Dest : 0x00000000 ID : 0x00000000 Src : 0x00000000 Sta : 0xC0000004 DestID : 0x00000000 Cmd : 0x00000001 SrcID : 0x00000000 Ext : 0x00000000 Len : 0x00000000 Rout : 0x00000000 Data: Start read/write IO-Data! ErrorDemo settingrunning Bus<Strg state+ lRetc> =to 0x800C0012!stop: ---Error Readreading /IO WriteData Block Information --- Read CONTROL Block 00 00 00 00 Write CONTROL Block Read COMMON Status Block 01 00 00 00 Write COMMON Status Block Error writing to common status block. lRet = 0x800A0006 Read EXTENDED Status Block 00 00 00 00 Write EXTENDED Status Block Error writing to extended status block. lRet = 0x800A0006 --- Event handling demo --- Sync-handshake mode: 0x02 (host controlled) Error: 0x800A001A, <Interrupt is disabled> --- Set Bus / Host State Demo --- Set CIFX_HOST_STATE_READY! CIFX_HOST_STATE_READ, state 1 ! Error CIFX_BUS_STATE_ON, state 0, error 0x800C0012 ! CIFX_BUS_STATE_OFF, state 0 ! Set CIFX_HOST_STATE_NOT_READY! CIFX_HOST_STATE_READ, state 0 ! State = 0x00000000area! State = 0x800c0012 -> Device not running (running flag failed) ---------------------------------------------------- --- Read / Write Block Information --- Read CONTROL Block 01 00 00 00 Write CONTROL Block Read COMMON Status Block 01 00 00 00 Write COMMON Status Block Error writing to common status block State = 0x800a0006 -> Invalid command Read EXTENDED Status Block 00 00 00 00 Write EXTENDED Status Block Error writing to extended status block. State = 0x800a0006 -> Invalid command ---------------------------------------------------- pi@raspberrypi:~/V2.1.1.0/V2.1.1.0/examples/buildpycifx $ |