I-PyTool Modbus iyithuluzi elihle lokuthuthukisa, ukulungisa iphutha nokuqapha iModbus.
Ifaka amandla weskripthi sePython esikunikeza ukuguquguquka okukhulu kakhulu.
Kungani amandla weskripthi afiseleka ngethuluzi leModbus?
Onjiniyela bakagesi bakuthola kusetshenziswa kalula ukusebenzisa into ephethwe ngesandla efana nefoni noma ithebhulethi ye-Android ukulungisa iphutha noma ukuqapha ukuxhumana kweModbus enkundleni, efektri noma elebhu.
Kepha cishe lonke uhlelo lokuxhumana lweModbus luthole ifomethi yalo yedatha.
Ukusesha olwandle lwedatha ye-hex efana ne- "02a5b4ca .... ff000803" nokuzama ukuthola ukuthi kwenzakalani akumnandi neze.
Yilapho iPyTool Modbus iza izosiza.
Ngokwazi ukusebenzisa iskripthi sangokwezifiso sePython, iPyTool Modbus ingafunda iphinde ihlolisise noma iyiphi idatha etholakele, iyikhombise ngendlela oyifunayo, futhi isebenze ngokufanele lapho kudingeka.
Kunezibonelo zeskripthi zokuqalisa okusheshayo. Vele ukopishe bese unamathisela eyodwa yazo ukuze uzame.
Kukhona futhi isikhombimsebenzisi esibonakalayo sokulawulwa kweModbus sokusetshenziswa okujwayelekile.
Ixhasa ukusakaza okuyisisekelo kwabashayeli be-USB serial, kufaka phakathi:
Umshayeli we-FTDI
CDC ACM umshayeli
Umshayeli we-CP210x
CH34x umshayeli
Umshayeli we-PL2303
Umhlahlandlela Jikelele Weskripthi
=================
* Uhlobo lwePython olusetshenziswe kulolu hlelo lokusebenza ngu-3.8.
* Lolu hlelo lokusebenza aluklanyelwe njengomhleli weskripthi yize iskripthi singahlelwa emkhakheni weskripthi.
Indlela enhle ukusebenzisa umhleli wesikripthi sakho osithandayo bese ukopisha bese unamathisela iskripthi.
* Njalo sebenzisa izikhala ezi-4 zokuhlehlisa ukugwema amaphutha axakile.
* Amaphakeji amaningi kulabhulali ejwayelekile yePython ayatholakala ukungenisa.
* Uma kusadingeka i-loop, hlala usebenzisa i- `app.running_script` njengesimo ukumisa iskripthi kahle.
* Sebenzisa i- `app.version` ukuthola umucu wenguqulo yohlelo lokusebenza.
* Sebenzisa i- `app.get_output ()` ukuthola inkambu yokukhipha yeskripthi njengeyunithi yezinhlamvu.
* Sebenzisa `app.set_output (object)` ukukhombisa `into` emkhakheni wokukhipha weskripthi njengeyunithi yezinhlamvu.
* Sebenzisa i- `` app.print_text (object) `njengesinqamuleli se-` `app.set_output (app.get_output () + str (object))` ukufaka umbhalo enkambweni yokukhipha umbhalo.
* Sebenzisa i- `app.clear_text ()` njengesinqamuleli se- `app.set_output (" ")` ukusula inkambu yokukhipha iskripthi.
* Sebenzisa i- `` app.fc01_read_coils (mbid, addr, num) `ukuthumela ikhodi yokusebenza engu-01.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
num (int): Inombolo Yemininingwane
buyisa (uhlu lwe-int): Uhlu Lwedatha Oluceliwe
* Sebenzisa i- `` app.fc02_read_discrete_inputs (mbid, addr, num) `ukuthumela ikhodi yokusebenza 02 isicelo.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
num (int): Inombolo Yemininingwane
buyisa (uhlu lwe-int): Uhlu Lwedatha Oluceliwe
* Sebenzisa i- `app.fc03_read_holding_registers (mbid, addr, num)` ukuthumela isicelo sekhodi 03.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
num (int): Inombolo Yemininingwane
buyisa (uhlu lwe-int): Uhlu Lwedatha Oluceliwe
* Sebenzisa i- `` app.fc04_read_input_registers (mbid, addr, num) `ukuthumela isicelo ikhodi 04.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
num (int): Inombolo Yemininingwane
buyisa (uhlu lwe-int): Uhlu Lwedatha Oluceliwe
* Sebenzisa i- `` app.fc05_write_single_coil (mbid, addr, val) `ukuthumela isicelo sekhodi 05.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
val (int): Inani ledatha
return (int): Inombolo Yemininingwane (njalo 1)
* Sebenzisa i- `` app.fc06_write_single_register (mbid, addr, val) `ukuthumela isicelo sekhodi 06.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
val (int): Inani ledatha
return (int): Inombolo Yemininingwane (njalo 1)
* Sebenzisa i- `` app.fc15_write_multiple_coils (mbid, addr, vals) `ukuthumela ikhodi yokusebenza engu-15.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
vals (uhlu lwe-int): Uhlu Lwamavelu Wedatha
return (int): Inombolo Yemininingwane
* Sebenzisa i- `` app.fc16_write_multiple_registers (mbid, addr, vals) `ukuthumela isicelo sekhodi 16.
mbid (int): I-Modbus ID
i-addr (int) Ikheli ledatha
vals (uhlu lwe-int): Uhlu Lwamavelu Wedatha
return (int): Inombolo Yemininingwane
* Sebenzisa i- `app.msg_out` ne-`app.msg_in` ukuhlola imiyalezo yesicelo nempendulo.
* Sebenzisa i- `` app.log_file (text) `ukusindisa ifayela lokungena kusitoreji.
Ifayela lokungena likhona lapha [Uhla lwemibhalo Yesitoreji] / PyToolModbus / log_ [Isitembu sesikhathi se-UTC] .txt.
umbhalo (str): Okuqukethwe kombhalo
buyisa (str): Indlela Ephelele Yefayela
Kubuyekezwe ngo-
Jul 4, 2021