Giter VIP home page Giter VIP logo

Comments (4)

mbuesch avatar mbuesch commented on August 19, 2024

Hi. Thanks for your question.

This probably is where things go wrong:

DPM1: Ignoring telegram in DataExchange with slave 5:
DpTelegram(da=0x02, sa=0x05, fc=0x02, dsap=None, ssap=None, du=Empty)

Your et200s probably sends something that's not yet supported by pyprofibus.
Please check what telegram that is.

from pyprofibus.

DHavron avatar DHavron commented on August 19, 2024

DPM1: Ignoring telegram in DataExchange with slave 5:
DpTelegram(da=0x02, sa=0x05, fc=0x02, dsap=None, ssap=None, du=Empty)

this telegram was received due to missing data in the parameter "output_size=0"

now there is an error when getting data

DPM1: Trying to initialize slave 5...
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: RX   10 02 05 00 07 16
DPM1: slave[05].state --> 'Wait for diag'
DPM1: Requesting Slave_Diag from slave 5...
PHY-serial: TX   68 05 05 68 85 82 6D 3C 3E EE 16
PHY-serial: RX   68 28 28 68 82 85 08 3E 3C 02 05 00 FF 80 6A 49 00 00 00 00 00 00 00 00 14 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 16
DPM1: slave[05].state --> 'Wait for Prm'
DPM1: Sending Set_Prm to slave 5...
PHY-serial: TX   68 29 29 68 85 82 5D 3D 3E B8 1E 01 00 80 6A 01 40 01 00 11 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 01 00 20 08 00 20 08 00 85 16
PHY-serial: RX   E5
DPM1: slave[05].state --> 'Wait for Cfg'
DPM1: Sending Chk_Cfg to slave 5...
PHY-serial: TX   68 08 08 68 85 82 7D 3E 3E 00 20 10 30 16
PHY-serial: RX   E5
DPM1: slave[05].state --> 'Request diag and wait for DX-ready'
DPM1: Requesting Slave_Diag (WDXRDY) from slave 5...
PHY-serial: TX   68 05 05 68 85 82 5D 3C 3E DE 16
PHY-serial: RX   68 28 28 68 82 85 08 3E 3C 00 0C 00 02 80 6A 49 00 00 00 00 00 00 00 00 14 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 16
DPM1: slave[05].state --> 'Data_Exchange'
DPM1: Initialization finished. Running Data_Exchange with slave 5...
PHY-serial: TX   68 05 05 68 05 02 7D 01 00 85 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 5D 01 00 65 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 7D 01 00 85 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 5D 01 00 65 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 7D 01 00 85 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 5D 01 00 65 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 7D 01 00 85 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 5D 01 00 65 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 7D 01 00 85 16
DPM1: Communication lost in Data_Exchange or Slave_Diag.
DPM1: slave[05].state --> 'Init'
DPM1: Trying to initialize slave 5...
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: RX (fragment)   FD DE BE
DPM1: RX error: PHY-serial: Failed to get received telegram size: Invalid telegram format.
PHY-serial: TX   10 05 02 49 50 16
PHY-serial: RX   10 02 05 00 07 16
DPM1: slave[05].state --> 'Wait for diag'
DPM1: Requesting Slave_Diag from slave 5...
PHY-serial: TX   68 05 05 68 85 82 5D 3C 3E DE 16
PHY-serial: RX   68 28 28 68 82 85 08 3E 3C 02 05 00 FF 80 6A 49 00 00 00 00 00 00 00 00 14 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 16
DPM1: slave[05].state --> 'Wait for Prm'
DPM1: Sending Set_Prm to slave 5...
PHY-serial: TX   68 29 29 68 85 82 7D 3D 3E B8 1E 01 00 80 6A 01 40 01 00 11 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 01 00 20 08 00 20 08 00 A5 16
PHY-serial: RX   E5
DPM1: slave[05].state --> 'Wait for Cfg'
DPM1: Sending Chk_Cfg to slave 5...
PHY-serial: TX   68 08 08 68 85 82 5D 3E 3E 00 20 10 10 16
PHY-serial: RX   E5
DPM1: slave[05].state --> 'Request diag and wait for DX-ready'
DPM1: Requesting Slave_Diag (WDXRDY) from slave 5...
PHY-serial: TX   68 05 05 68 85 82 7D 3C 3E FE 16
PHY-serial: RX   68 28 28 68 82 85 08 3E 3C 00 0C 00 02 80 6A 49 00 00 00 00 00 00 00 00 14 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 16
DPM1: slave[05].state --> 'Data_Exchange'
DPM1: Initialization finished. Running Data_Exchange with slave 5...
PHY-serial: TX   68 05 05 68 05 02 5D 01 00 65 16
PHY-serial: RX   10 02 05 02 09 16
DPM1:  >ERROR<  Slave 5: The received data size (0 bytes) does not match the slave's configured output_size (2 bytes).
PHY-serial: TX   68 05 05 68 05 02 7D 01 00 85 16
PHY-serial: RX   10 02 05 02 09 16

my code



import sys
sys.path.insert(0, "..")
import pyprofibus

def main(confdir=".", watchdog=None):
	master = None
	try:
		# Parse the config file.
		config = pyprofibus.PbConf.fromFile(confdir + "/example_et200s.conf")

		# Create a DP master.
		master = config.makeDPM()

		# Create the slave descriptions.
		outData = {}
		for slaveConf in config.slaveConfs:
			slaveDesc = slaveConf.makeDpSlaveDesc()

			# Set User_Prm_Data
			dp1PrmMask = bytearray((pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM0_FAILSAFE,
						pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM1_REDCFG,0x00))
						
			dp1PrmSet  = bytearray((pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM0_FAILSAFE,
						pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM1_REDCFG,0x00))
						
			slaveDesc.setUserPrmData(slaveConf.gsd.getUserPrmData(dp1PrmMask=dp1PrmMask,
									      dp1PrmSet=dp1PrmSet))

			# Register the ET-200S slave at the DPM
			master.addSlave(slaveDesc)

			# Set initial output data.	
			outData[slaveDesc.slaveAddr] =bytearray((0x00,0x00))
			
		# Initialize the DPM
		master.initialize()

		# Cyclically run Data_Exchange.
		while True:
			# Write the output data.
			for slaveDesc in master.getSlaveList():
				slaveDesc.setMasterOutData(outData[slaveDesc.slaveAddr])

			# Run slave state machines.
			handledSlaveDesc = master.run()
	
			# Get the in-data (receive)
			if handledSlaveDesc:
				
				inData = handledSlaveDesc.getMasterInData()
				
				outData[handledSlaveDesc.slaveAddr] = bytearray((0x01,0x00))
				#outData[handledSlaveDesc.slaveAddr][1] = 1
				
	except pyprofibus.ProfibusError as e:
		print("Terminating: %s" % str(e))
		return 1
	finally:
		if master:
			master.destroy()
	return 0

if __name__ == "__main__":
	import sys
	sys.exit(main())

my config file

; ----------------------------------------------- ;
;                                                 ;
; PROFIBUS configuration                          ;
;                                                 ;
; This file configures a pyprofibus instance.     ;
;                                                 ;
; ----------------------------------------------- ;


; General settings
[PROFIBUS]

; Enable/disable debug mode.
; 0 -> no debugging.
; 1 -> DP debugging.
; 2 -> DP and PHY debugging.
debug=2


; PHY protocol layer configuration
[PHY]

; The PHY layer driver type.
type=serial
;type=fpga
;type=dummy_slave

; Only for type=serial:
; The PHY device name/path.
; Can be a device like /dev/ttyS0 or /dev/ttyAMA0 ttyUSB0
;dev=/dev/ttyS0
dev=/dev/ttyUSB0

; Only for type=serial:
; Serial line flow control and handshaking
rtscts=False
dsrdtr=False

; Only for type=fpga:
; SPI bus (to PHY FPGA) configuration.
spiBus=0
spiCS=0
spiSpeedHz=2500000

; The Profibus on-wire baud rate.
;baud=9600
baud=19200
;baud=45450
;baud=93750
;baud=187500
;baud=500000
;baud=1500000
;baud=3000000
;baud=6000000
;baud=12000000


; FDL protocol layer configuration
[FDL]


; DP protocol layer configuration
[DP]

; The master device class. Either 1 or 2.
master_class=1

; The Profibus address of this device.
master_addr=2


; ---
; Slave configurations
; Add as many [SLAVE_xxx] sections as needed.
; ---

; First slave configuration
[SLAVE_0]

; Optional slave name. Will be stored in slaveConf.name and slaveDesc.name.
; pyprofibus does not use the name internally.
name=et200s

; This slave's Profibus address
addr=5

; The path to the GSD file.
gsd=si05806a.gse

; Boolean: Sync mode enabled/available?
sync_mode=1

; Boolean: Freeze mode enabled/available?
freeze_mode=1

; 8 bit integer specifying the Profibus group ident mask.
group_mask=1

; This slave's watchdog timeout, in milliseconds.
watchdog_ms=300

; Module configuration.
; For each module plugged into the slave, add a module_xxx
; entry with the name of the module.
; The module name must match the name from the GSD file (approximately).
; The modules are used in the order of the index number.
module_0=6ES7 138-4CA01-0AA0 PM-E DC24V
module_1=6ES7 132-4BF00-0AA0 8DO
module_2=6ES7 131-4BF00-0AA0 8DI


; 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 = 2

; Request and interpret a slave diagnosis every n Data_Exchange telegrams.
; n defaults to 0, which means: Never periodically request diagnosis.
; If periodic diagnosis is switched off, then diagnostic information will only be requested on faults.
; Note that input-only slaves (output_size=0) probably need a non-zero diag_period.
diag_period=0

GSD file

from pyprofibus.

DHavron avatar DHavron commented on August 19, 2024

Hi. Thanks for your question.

This probably is where things go wrong:

DPM1: Ignoring telegram in DataExchange with slave 5:
DpTelegram(da=0x02, sa=0x05, fc=0x02, dsap=None, ssap=None, du=Empty)

Your et200s probably sends something that's not yet supported by pyprofibus. Please check what telegram that is.

with connection and data exchange it turned out only when and file GSD deleted all information about 6ES7 138-4CA01-0AA0 PM-E DC24V, then an error appears on the hardware, but the data exchange works. when I return the module to file GSD data is not received.

GSD:

;=================================================================
; GSD-File for ET 200S                            Siemens AG
; MLFB   :  6ES7 151-1AA04-0AB0
;
; Date   :  08.02.11  V 1.8  RG, HA, GW, CK, PeCa
;
; File   : "SI03806A.GSG"
;=================================================================
; reserved Text   Refs : 1 ... 158
; reserved Prm    Refs : 1 ... 513;    1299 ... 1328 (DPV1)
; reserved Module Refs : 1 ... 353
;=================================================================
#Profibus_DP
;-------- <Unit-Definition-List> ---------------
GSD_Revision=5
Vendor_Name="SIEMENS"
Model_Name="ET 200S (IM151) DPV1"
Revision = "V1.8"
Ident_Number = 0x806A
Protocol_Ident = 0
Station_Type = 0
FMS_supp = 0
Hardware_Release = "A1.0"
Software_Release = "Z1.0"
9.6_supp    = 1
19.2_supp   = 1
45.45_supp  = 1
93.75_supp  = 1
187.5_supp  = 1
500_supp    = 1
1.5M_supp   = 1
3M_supp     = 1
6M_supp     = 1
12M_supp    = 1
MaxTsdr_9.6   = 15
MaxTsdr_19.2  = 15
MaxTsdr_45.45 = 15
MaxTsdr_93.75 = 15
MaxTsdr_187.5 = 15
MaxTsdr_500   = 15
MaxTsdr_1.5M  = 25
MaxTsdr_3M    = 50
MaxTsdr_6M    = 100
MaxTsdr_12M   = 200
Implementation_Type = "DPC31"
Bitmap_Device = "SI806A_N"
Bitmap_SF     = "SI806A_S"
; Slave-Specification:
OrderNumber="6ES7 151-1AA04-0AB0"
Freeze_Mode_supp = 1
Sync_Mode_supp = 1
Auto_Baud_supp = 1
Fail_Safe = 1
Min_Slave_Intervall = 1
Max_Diag_Data_Len = 122
Modul_Offset = 1
Slave_Family=3@ET200S                       ; Device Family
Family_Name = "SIMATIC"
Modular_Station = 1
Max_Module      = 63
Max_Input_Len   = 244
Max_Output_Len  = 244
Max_Data_Len    = 488
Redundancy = 0                              ; no redundant transmission
Repeater_Ctrl_Sig = 2                       ; Signal CNTR-P connected
24V_Pins = 0                                ; Signal M24V and P24V not connected
Set_Slave_Add_supp = 0

;Revision 3 specific parameter
Diag_Update_Delay=0
Fail_safe_required=0
DPV1_Slave=1
C1_Read_Write_supp=1
C1_Max_Data_Len=240
C1_Response_Timeout=100
C1_Read_Write_required=0
C2_Read_Write_supp=1
C2_Max_Data_Len=240
C2_Response_Timeout=100
C2_Read_Write_required=0
C2_Max_Count_Channels=3
Max_Initiate_PDU_Length=52
Diagnostic_Alarm_supp=1
Process_Alarm_supp=1
Pull_Plug_Alarm_supp=1
Status_Alarm_supp=0
Update_Alarm_supp=0
Manufacturer_Specific_Alarm_supp=0
Extra_Alarm_SAP_supp=1
Alarm_Sequence_Mode_Count=32
Alarm_Type_Mode_supp=1
Diagnostic_Alarm_required=0
Process_Alarm_required=0
Pull_Plug_Alarm_required=0
Status_Alarm_required=0
Update_Alarm_required=0
Manufacturer_Specific_Alarm_required=0
WD_Base_1ms_supp=1
Check_Cfg_Mode=1
Publisher_supp=1
Prm_Block_Structure_supp=0
DS248_FCT = 0xF111

;---------------------- Head Parameter -------------------------

; "Die ersten 3 Byte entsprechen den DPV1-Prm-Bytes 8-10, die restlichen
;  17 Bytes stehen fuer die Geraeteparametrierung zur Verfuegung"

Max_User_Prm_Data_Len = 237
Ext_User_Prm_Data_Const(0) = 0x20,0x01,0x00,0x11,0x21,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00


; <Module-Definition-List>


Module = "6ES7 131-4BF00-0AA0 8DI" 0x10
275
Ext_Module_Prm_Data_Len = 3
Ext_User_Prm_Data_Const(0) = 0x20,0x08,0x00
EndModule


Module = "6ES7 132-4BF00-0AA0 8DO" 0x20
276
Ext_Module_Prm_Data_Len = 3
Ext_User_Prm_Data_Const(0) = 0x20,0x08,0x00
EndModule


;Module = "6ES7 138-4CA01-0AA0 PM-E DC24V" 0x00
;229
;Ext_Module_Prm_Data_Len = 3
;Ext_User_Prm_Data_Const(0) = 0x20,0x01,0x00
;Ext_User_Prm_Data_Ref(2) = 41
;EndModule

from pyprofibus.

mbuesch avatar mbuesch commented on August 19, 2024

Your code, configuration or gsd probably doesn't match your physical setup.
Unfortunately the slaves are very picky about this and will usually completely refuse to work, if a very small detail is wrong.

from pyprofibus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.