首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pyprofibus:为PRM找到合适的配置和配置

pyprofibus:为PRM找到合适的配置和配置
EN

Stack Overflow用户
提问于 2022-10-06 08:08:36
回答 1查看 90关注 0票数 0

我们以前有一个功能程序在转换器上运行pyprofibus,并附带一个gsd文件HMS_1810.gsd。运行该程序的计算机有一个来自HMS的Profibus-DP主仿真器,连接在传感器的串口上,电缆的另一端作为usb适配器( linux系统上的接口dev=/dev/ttyUSB0 )。

现在我们想要使用pyprofibus,除了使用M40的换能器的新模型和HMSB1815.gsd变体之外,硬件设置基本相同。还不清楚新的pyprofibus.conf文件应该如何引用每个新模块。从我在gsd文件中看到的情况来看,它现在使用的是DP-V1而不是DP-V0。

当我运行新程序(附加"frequency_reader_new.conf“、"frequency_reader_new.py”和"HMSB1815.gsd")时,我得到了响应:

代码语言:javascript
复制
config: <pyprofibus.conf.PbConf object at 0x7feaa09c83d0>
master : <pyprofibus.dp_master.DPM1 object at 0x7feaa076eb40>
<pyprofibus.conf.PbConf._SlaveConf object at 0x7feaa09c8ac0> -- done!
<pyprofibus.dp_master.DPM1 object at 0x7feaa076eb40> -- initialized
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
DPM1:  >ERROR<  Slave 5 reports a faulty configuration (Chk_Cfg).
  • 考虑到上一个程序中的dp1Prm设置非常简单,那么只在新程序中运行类似的设置可以吗?
  • 在前面的程序.conf中,所使用的模块在模块名称之后使用了相关的“字节码”。在新.conf的上下文中,每个使用的模块应该使用哪个字节或全部字节?
  • 确切地说,Chk_Cfg参数是错误的吗?

源代码和倾诉:

HMSB1815.gsd

代码语言:javascript
复制
;===============================================================================
; PROFIBUS Device Database of HMS Industrial Networks.
;
; Model:       Anybus CompactCom 40 DP-V1
; Description: Anybus-CC 40 PROFIBUS DP-V1 slave
; Language:    English
; Author:      HMS Industrial Networks
; WWW:         www.anybus.com
;
;===============================================================================
#Profibus_DP

GSD_Revision        = 5

; Device identification
Vendor_Name         = "HMS Industrial Networks"
Model_Name          = "Anybus CompactCom 40 DP-V1"
Revision            = "1.8"
Ident_Number        = 0x1815
Protocol_Ident      = 0                ; DP protocol
Station_Type        = 0                ; Slave device
FMS_supp            = 0                ; FMS not supported
Slave_Family        = 0                ; General device
Hardware_Release    = "Version 1"
Software_Release    = "Version 1.08"
Bitmap_Device       = "ABCC-40"

; Supported hardware features
Redundancy          = 0                ; not supported
Repeater_Ctrl_Sig   = 2                ; TTL
24V_Pins            = 0                ; not connected
Implementation_Type = "NP40"

; Supported DP features
Freeze_Mode_supp    = 1                ; supported
Sync_Mode_supp      = 1                ; supported
Auto_Baud_supp      = 1                ; supported
Set_Slave_Add_supp  = 1                ; supported
Fail_Safe           = 1                ; supported

; Maximum polling frequency
Min_Slave_Intervall = 1                ; 100 us

; I/O related keywords
Modular_Station     = 1                ; modular
Max_Module          = 40
Max_Input_Len       = 244
Max_Output_Len      = 244
Max_Data_Len        = 488
Modul_Offset        = 1

; Parameterization related keywords
Prm_Block_Structure_supp   = 0
Max_User_Prm_Data_Len      = 3              ; To be changed if the application requests user parameter data
Ext_User_Prm_Data_Const(0) = 0xC0,0x00,0x00

; Diagnostic related keywords
Max_Diag_Data_Len   = 244

;================================================================================
;======= SUPPORTED BAUDRATES ====================================================
;================================================================================

; Supported baudrates
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

; Maximum responder time for supported baudrates
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

;================================================================================
;======= DPV1 FEATURES ==========================================================
;================================================================================

; DPV1 related keywords
DPV1_Slave              = 1
Check_Cfg_Mode          = 1

C1_Read_Write_supp      = 1
C1_Max_Data_Len         = 240
C1_Response_Timeout     = 100  ;1 sec

C2_Read_Write_supp      = 1
C2_Max_Data_Len         = 240
C2_Response_Timeout     = 100  ;1 sec
C2_Max_Count_Channels   = 2
Max_Initiate_PDU_Length = 52

Ident_Maintenance_supp  = 1

; Alarm
Extra_Alarm_SAP_supp                  = 1
Alarm_Sequence_Mode_Count             = 32
Alarm_Type_Mode_supp                  = 1

Diagnostic_Alarm_supp                 = 1
Process_Alarm_supp                    = 0
Pull_Plug_Alarm_supp                  = 0
Status_Alarm_supp                     = 0
Update_Alarm_supp                     = 0
Manufacturer_Specific_Alarm_supp      = 0

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

;================================================================================
;======= Informations of the Status diagnostic messages =========================
;================================================================================

;Status diagnostic messages
Unit_Diag_Area=16-17
Value(0)  = "Status not changed"
Value(1)  = "Status appears"
Value(2)  = "Status disappears"
Unit_Diag_Area_End

Unit_Diag_Area=24-31
Value(0)   = "Minor, recoverable"
Value(16)  = "Minor, unrecoverable"
Value(32)  = "Major, recoverable"
Unit_Diag_Area_End

Unit_Diag_Area=32-39
Value(16)  = "Generic Error"
Value(32)  = "Current"
Value(33)  = "Current, device input side"
Value(34)  = "Current, inside the device"
Value(35)  = "Current, device output side"
Value(48)  = "Voltage"
Value(49)  = "Mains Voltage"
Value(50)  = "Voltage inside the device"
Value(51)  = "Output Voltage"
Value(64)  = "Temperature"
Value(65)  = "Ambient Temperature"
Value(66)  = "Device Temperature"
Value(80)  = "Device Hardware"
Value(96)  = "Device Software"
Value(97)  = "Internal Software"
Value(98)  = "User Software"
Value(99)  = "Data Set"
Value(112) = "Additional Modules"
Value(128) = "Monitoring"
Value(129) = "Communication"
Value(130) = "Protocol Error"
Value(144) = "External Error"
Value(240) = "Additional Functions"
Unit_Diag_Area_End

;--------------------------------------
; Diagnostic Texts for Module Status
;--------------------------------------
UnitDiagType = 130
X_Unit_Diag_Area = 24-25
X_Value(1) = "Slot 1: Module error"
X_Value(2) = "Slot 1: wrong submodule"
X_Value(3) = "Slot 1: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 26-27
X_Value(1) = "Slot 2: Module error"
X_Value(2) = "Slot 2: wrong submodule"
X_Value(3) = "Slot 2: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 28-29
X_Value(1) = "Slot 3: Module error"
X_Value(2) = "Slot 3: wrong submodule"
X_Value(3) = "Slot 3: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 30-31
X_Value(1) = "Slot 4: Module error"
X_Value(2) = "Slot 4: wrong submodule"
X_Value(3) = "Slot 4: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 32-33
X_Value(1) = "Slot 5: Module error"
X_Value(2) = "Slot 5: wrong submodule"
X_Value(3) = "Slot 5: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 34-35
X_Value(1) = "Slot 6: Module error"
X_Value(2) = "Slot 6: wrong submodule"
X_Value(3) = "Slot 6: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 36-37
X_Value(1) = "Slot 7: Module error"
X_Value(2) = "Slot 7: wrong submodule"
X_Value(3) = "Slot 7: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 38-39
X_Value(1) = "Slot 8: Module error"
X_Value(2) = "Slot 8: wrong submodule"
X_Value(3) = "Slot 8: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 40-41
X_Value(1) = "Slot 9: Module error"
X_Value(2) = "Slot 9: wrong submodule"
X_Value(3) = "Slot 9: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 42-43
X_Value(1) = "Slot 10: Module error"
X_Value(2) = "Slot 10: wrong submodule"
X_Value(3) = "Slot 10: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 44-45
X_Value(1) = "Slot 11: Module error"
X_Value(2) = "Slot 11: wrong submodule"
X_Value(3) = "Slot 11: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 46-47
X_Value(1) = "Slot 12: Module error"
X_Value(2) = "Slot 12: wrong submodule"
X_Value(3) = "Slot 12: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 48-49
X_Value(1) = "Slot 13: Module error"
X_Value(2) = "Slot 13: wrong submodule"
X_Value(3) = "Slot 13: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 50-51
X_Value(1) = "Slot 14: Module error"
X_Value(2) = "Slot 14: wrong submodule"
X_Value(3) = "Slot 14: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 52-53
X_Value(1) = "Slot 15: Module error"
X_Value(2) = "Slot 15: wrong submodule"
X_Value(3) = "Slot 15: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 54-55
X_Value(1) = "Slot 16: Module error"
X_Value(2) = "Slot 16: wrong submodule"
X_Value(3) = "Slot 16: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 56-57
X_Value(1) = "Slot 17: Module error"
X_Value(2) = "Slot 17: wrong submodule"
X_Value(3) = "Slot 17: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 58-59
X_Value(1) = "Slot 18: Module error"
X_Value(2) = "Slot 18: wrong submodule"
X_Value(3) = "Slot 18: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 60-61
X_Value(1) = "Slot 19: Module error"
X_Value(2) = "Slot 19: wrong submodule"
X_Value(3) = "Slot 19: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 62-63
X_Value(1) = "Slot 20: Module error"
X_Value(2) = "Slot 20: wrong submodule"
X_Value(3) = "Slot 20: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 64-65
X_Value(1) = "Slot 21: Module error"
X_Value(2) = "Slot 21: wrong submodule"
X_Value(3) = "Slot 21: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 66-67
X_Value(1) = "Slot 22: Module error"
X_Value(2) = "Slot 22: wrong submodule"
X_Value(3) = "Slot 22: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 68-69
X_Value(1) = "Slot 23: Module error"
X_Value(2) = "Slot 23: wrong submodule"
X_Value(3) = "Slot 23: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 70-71
X_Value(1) = "Slot 24: Module error"
X_Value(2) = "Slot 24: wrong submodule"
X_Value(3) = "Slot 24: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 72-73
X_Value(1) = "Slot 25: Module error"
X_Value(2) = "Slot 25: wrong submodule"
X_Value(3) = "Slot 25: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 74-75
X_Value(1) = "Slot 26: Module error"
X_Value(2) = "Slot 26: wrong submodule"
X_Value(3) = "Slot 26: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 76-77
X_Value(1) = "Slot 27: Module error"
X_Value(2) = "Slot 27: wrong submodule"
X_Value(3) = "Slot 27: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 78-79
X_Value(1) = "Slot 28: Module error"
X_Value(2) = "Slot 28: wrong submodule"
X_Value(3) = "Slot 28: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 80-81
X_Value(1) = "Slot 29: Module error"
X_Value(2) = "Slot 29: wrong submodule"
X_Value(3) = "Slot 29: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 82-83
X_Value(1) = "Slot 30: Module error"
X_Value(2) = "Slot 30: wrong submodule"
X_Value(3) = "Slot 30: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 84-85
X_Value(1) = "Slot 31: Module error"
X_Value(2) = "Slot 31: wrong submodule"
X_Value(3) = "Slot 31: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 86-87
X_Value(1) = "Slot 32: Module error"
X_Value(2) = "Slot 32: wrong submodule"
X_Value(3) = "Slot 32: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 88-89
X_Value(1) = "Slot 33: Module error"
X_Value(2) = "Slot 33: wrong submodule"
X_Value(3) = "Slot 33: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 90-91
X_Value(1) = "Slot 34: Module error"
X_Value(2) = "Slot 34: wrong submodule"
X_Value(3) = "Slot 34: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 92-93
X_Value(1) = "Slot 35: Module error"
X_Value(2) = "Slot 35: wrong submodule"
X_Value(3) = "Slot 35: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 94-95
X_Value(1) = "Slot 36: Module error"
X_Value(2) = "Slot 36: wrong submodule"
X_Value(3) = "Slot 36: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 96-97
X_Value(1) = "Slot 37: Module error"
X_Value(2) = "Slot 37: wrong submodule"
X_Value(3) = "Slot 37: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 98-99
X_Value(1) = "Slot 38: Module error"
X_Value(2) = "Slot 38: wrong submodule"
X_Value(3) = "Slot 38: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 100-101
X_Value(1) = "Slot 39: Module error"
X_Value(2) = "Slot 39: wrong submodule"
X_Value(3) = "Slot 39: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 102-103
X_Value(1) = "Slot 40: Module error"
X_Value(2) = "Slot 40: wrong submodule"
X_Value(3) = "Slot 40: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 104-105
X_Value(1) = "Slot 41: Module error"
X_Value(2) = "Slot 41: wrong submodule"
X_Value(3) = "Slot 41: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 106-107
X_Value(1) = "Slot 42: Module error"
X_Value(2) = "Slot 42: wrong submodule"
X_Value(3) = "Slot 42: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 108-109
X_Value(1) = "Slot 43: Module error"
X_Value(2) = "Slot 43: wrong submodule"
X_Value(3) = "Slot 43: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 110-111
X_Value(1) = "Slot 44: Module error"
X_Value(2) = "Slot 44: wrong submodule"
X_Value(3) = "Slot 44: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 112-113
X_Value(1) = "Slot 45: Module error"
X_Value(2) = "Slot 45: wrong submodule"
X_Value(3) = "Slot 45: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 114-115
X_Value(1) = "Slot 46: Module error"
X_Value(2) = "Slot 46: wrong submodule"
X_Value(3) = "Slot 46: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 116-117
X_Value(1) = "Slot 47: Module error"
X_Value(2) = "Slot 47: wrong submodule"
X_Value(3) = "Slot 47: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 118-119
X_Value(1) = "Slot 48: Module error"
X_Value(2) = "Slot 48: wrong submodule"
X_Value(3) = "Slot 48: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 120-121
X_Value(1) = "Slot 49: Module error"
X_Value(2) = "Slot 49: wrong submodule"
X_Value(3) = "Slot 49: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 122-123
X_Value(1) = "Slot 50: Module error"
X_Value(2) = "Slot 50: wrong submodule"
X_Value(3) = "Slot 50: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 124-125
X_Value(1) = "Slot 51: Module error"
X_Value(2) = "Slot 51: wrong submodule"
X_Value(3) = "Slot 51: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 126-127
X_Value(1) = "Slot 52: Module error"
X_Value(2) = "Slot 52: wrong submodule"
X_Value(3) = "Slot 52: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 128-129
X_Value(1) = "Slot 53: Module error"
X_Value(2) = "Slot 53: wrong submodule"
X_Value(3) = "Slot 53: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 130-131
X_Value(1) = "Slot 54: Module error"
X_Value(2) = "Slot 54: wrong submodule"
X_Value(3) = "Slot 54: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 132-133
X_Value(1) = "Slot 55: Module error"
X_Value(2) = "Slot 55: wrong submodule"
X_Value(3) = "Slot 55: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 134-135
X_Value(1) = "Slot 56: Module error"
X_Value(2) = "Slot 56: wrong submodule"
X_Value(3) = "Slot 56: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 136-137
X_Value(1) = "Slot 57: Module error"
X_Value(2) = "Slot 57: wrong submodule"
X_Value(3) = "Slot 57: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 138-139
X_Value(1) = "Slot 58: Module error"
X_Value(2) = "Slot 58: wrong submodule"
X_Value(3) = "Slot 58: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 140-141
X_Value(1) = "Slot 59: Module error"
X_Value(2) = "Slot 59: wrong submodule"
X_Value(3) = "Slot 59: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 142-143
X_Value(1) = "Slot 60: Module error"
X_Value(2) = "Slot 60: wrong submodule"
X_Value(3) = "Slot 60: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 144-145
X_Value(1) = "Slot 61: Module error"
X_Value(2) = "Slot 61: wrong submodule"
X_Value(3) = "Slot 61: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 146-147
X_Value(1) = "Slot 62: Module error"
X_Value(2) = "Slot 62: wrong submodule"
X_Value(3) = "Slot 62: no submodule"
X_Unit_Diag_Area_End
X_Unit_Diag_Area = 148-149
X_Value(1) = "Slot 63: Module error"
X_Value(2) = "Slot 63: wrong submodule"
X_Value(3) = "Slot 63: no submodule"
X_Unit_Diag_Area_End
EndUnitDiagType

;================================================================================
;======= DEFINITIONS OF MODULES =================================================
;================================================================================

Module = "Bus Inc Num" 0x43,0xC0,0x00,0x01,0x00
1
EndModule
;
Module = "Data Inc Num" 0x43,0xC0,0x00,0x02,0x00
2
EndModule
;
Module = "I" 0x43,0xC0,0x00,0x03,0x00
3
EndModule
;
Module = "U" 0x43,0xC0,0x00,0x04,0x00
4
EndModule
;
Module = "P" 0x43,0xC1,0x00,0x05,0x00
5
EndModule
;
Module = "Q" 0x43,0xC1,0x00,0x06,0x00
6
EndModule
;
Module = "F" 0x43,0xC0,0x00,0x07,0x00
7
EndModule
;
Module = "F_HIRES" 0x43,0xC1,0x00,0x08,0x00
8
EndModule
;

frequency_reader.conf

代码语言:javascript
复制
; ----------------------------------------------- ;
;                                                 ;
; 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=0


; 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
dev=/dev/ttyUSB0
;ttyUSB0 is USB

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


; ---
; 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
; try another address for debugging
;addr=3

; The path to the GSD file.
gsd=/home/X/X/HMSB1815.gsd
;gsd=/home/X/X/HMS_1810.gsd

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

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

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

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

; 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.

; --- HMS1810 gsd file ---
;module_0="Input 1 byte" 0x90
;module_2="Input 2 words" 0xD1
;module_3="Input 4 words" 0xD3
;module_4 = "Output 1 byte" 0xA0
;module_5 = "Output 1 words" 0xE0
;module_6 = "Output 2 words" 0xE1
;module_7 = "Output 4 words" 0xE3

; used by SE3 frequency meters (HMS1810.gsd)
;module_0="Input 1 word" 0xD0
;module_1="Input 1 word" 0xD0
;module_2="Input 1 word" 0xD0
;module_3="Input 1 word" 0xD0
;module_4="Input 2 words" 0xD1
;module_5="Input 2 words" 0xD1
;module_6="Input 1 word" 0xD0
;module_7="Input 2 words" 0xD3

; --- HMSB1815 gsd file ---
;module_0="Bus Inc Num" 0x43,0xC0,0x00,0x01,0x00
;module_1="Data Inc Num" 0x43,0xC0,0x00,0x02,0x00
;module_2="I" 0x43,0xC0,0x00,0x03,0x00
;module_3="U" 0x43,0xC0,0x00,0x04,0x00
;module_4="P" 0x43,0xC0,0x00,0x05,0x00
;module_5="Q" 0x43,0xC0,0x00,0x06,0x00
;module_6="F" 0x43,0xC0,0x00,0x07,0x00
;module_7="F_HIRES" 0x43,0xC0,0x00,0x08,0x00
;
;module_0=Bus Inc Num
;module_1=Data Inc Num
;module_2=I
;module_3=U
;module_4=P
;module_5=Q
;module_6=F
module_7="F_HIRES"

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

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

; -- experiment with different input/output sizes //Axel
input_size=1
output_size=1

frequency_reader.py

代码语言:javascript
复制
### ONLY FOR BASIC TESTING OF PROFIBUS ON LIVE TILLQUIST DEVICE

import pyprofibus
import time
import asyncio
import sys
import os
import json
import ssl
import logging

from traceback import format_exc

CONF_PATH = "/home/X/X/frequency_reader.conf"

async def profibus_main():

    master = None
    config = pyprofibus.PbConf.fromFile(CONF_PATH)
    print(f"config: {config}")
    master = config.makeDPM()
    print(f"master : {master}")
    outData = {}
    for slave_conf in config.slaveConfs:

        slave_desc = slave_conf.makeDpSlaveDesc()

        #dp1PrmMask = bytearray((pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM0_V1MODE,
        #    pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM1_ALRMVEND,
        #    pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM2_ISO))
        #dp1PrmSet  = bytearray((pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM0_V1MODE,
        #    pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM1_ALRMVEND,
        #    pyprofibus.dp.DpTelegram_SetPrm_Req.DPV1PRM2_ISO))
        #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))


        #dp1PrmMask = bytearray([0x43,0xC0,0x00])
        #dp1PrmSet  = bytearray([0x43,0xC0,0x00])
        #slave_desc.setUserPrmData(slave_conf.gsd.getUserPrmData(dp1PrmMask=dp1PrmMask,
        #    dp1PrmSet=dp1PrmSet))

        master.addSlave(slave_desc)
        outData[slave_desc.name] = bytearray([0x08])
        slave = slave_desc.name
        print(f"{slave_conf} -- done!") # DEBUG
    master.initialize()
    print(f"{master} -- initialized") # DEBUG
    timeouts = 0


    while True:
        slave_desc.setOutData(outData[slave])
        handled_slave_desc = master.run()
        in_data = handled_slave_desc.getInData()
        if in_data is not None: print(f"in_data:\n{in_data}\n")
        

async def main():
    asyncio.create_task(profibus_main())

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.create_task(main())
    loop.run_forever()
    raise RuntimeError
EN

回答 1

Stack Overflow用户

发布于 2022-10-08 18:08:26

晚上好。我已经与gsdparser.py核对过,您的gsd文件对于pyprofibus是一致的。

解析器

看起来pyprofibus正确地识别了gsd文件,没有任何错误。因此,对于我来说,由于不通晓python文件是正确的,而且您在frequency_reader.py中有错误的参数。我想使用这个库从profibus值中读取来自的数据,使用廉价的rs485 usb转换器。你对这个图书馆有什么经验?这个库有用吗?我从来没有与profibus建立连接,因为我没有任何profibus dp设备可以连接。我在做dummy_slave。到目前为止,我已经创建了Tkinker,并与其进行了精确的沟通。

基于USB COM3的Profibus总线 --我注意到,在没有线程的情况下,通信会减少。仍然在寻找一些设备来检查通信是否正常。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73970508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档