Napisałem sub'a
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $nocompile
- ' odbiór danych z uart1 RS485
- Sub RS485ping
- Debug #Debug_ , "jestem w RS485ping_"
- ''Adres485 = 254
- ''Print #RS485 , Adres485 ; " ping_adress" ; Chr(13)
- ''Print #Debug_ , "Adres485tx=> " ; Adres485
- 'Print #Debug_ , "Adres485rx=> " ; RS485_adres_temp
- 'Print #Debug_ , "Name_device=>" ; Name_device
- For Adres485 = 1 To 255 Step 1
- Print #RS485 , Adres485 ; " ping_adress" ; Chr(13)
- Print #Debug_ , "Adres485tx=> " ; RS485
- Print #Debug_ , "Adres485rx=> " ; RS485_adres_temp
- Print #Debug_ , "Name_device=>" ; Name_device
- Next Adres485
- Return
- End Sub
jak ustawię na sztywno jeden adres
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $nocompile
- ' odbiór danych z uart1 RS485
- Sub RS485ping
- Debug #Debug_ , "jestem w RS485ping_"
- Adres485 = 254
- Print #RS485 , Adres485 ; " ping_adress" ; Chr(13)
- 'Print #Debug_ , "Adres485tx=> " ; Adres485
- 'Print #Debug_ , "Adres485rx=> " ; RS485_adres_temp
- 'Print #Debug_ , "Name_device=>" ; Name_device
- ' For Adres485 = 1 To 255 Step 1
- ' Print #RS485 , Adres485 ; " ping_adress" ; Chr(13)
- ' Print #Debug_ , "Adres485tx=> " ; RS485
- ' Print #Debug_ , "Adres485rx=> " ; RS485_adres_temp
- ' Print #Debug_ , "Name_device=>" ; Name_device
- ' Next Adres485
- Return
- End Sub
odbiór mam tak
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $nocompile
- ' odbiór danych z uart1 RS485
- Sub Uartrx1
- 'Reset Watchdog
- '##########################################################
- Print #Debug_ , "jestem w uar_rx1"
- Lcount_1 = Split(uart_command_1 , Getcommands_1(1) , " ") 'This choping coomand after space
- 'Debug Chr(13)
- Print #Debug_ , "lcount_1= " ; Lcount_1
- Print #Debug_ , "uart_command_1= " ; Uart_command_1
- Print #Debug_ , "Getcommands_1(1)= " ; Getcommands_1(1)
- Print #Debug_ , "Getcommands_1(2)= " ; Getcommands_1(2)
- Print #Debug_ , "Getcommands_1(3)= " ; Getcommands_1(3)
- 'Debug #Debug_ , " "; 'command>> az 0 0 'printing proper spaces
- Rs485_adres_temp = Val(getcommands_1(1)) 'zamien tekst na numer
- Print #Debug_ , "odebrlem poprawnie adres "
- 'Print #Debug_ , "adress " ; RS485_adres_temp
- Print #Debug_ , "Adres485rx=> " ; RS485_adres_temp
- Name_device = Getcommands_1(2)
- Print #Debug_ , "Name_device=>" ; Name_device
- Select Case Rs485_adres_temp
- Case Rs485_adres : 'komneda 1 case 1, sprawdzenie adresu
- ' Debug #Debug_ , "odebrlem poprawnie adres "
- 'Debug #Debug_ , "adress " ; RS485_adres_temp
- '-------------------------------------------------------------------------------------------
- Select Case Getcommands_1(2)
- Case uart1G2_c_1: 'azymut
- Print #Debug_ , "jestem w command 2, case 1 "
- Name_device = Getcommands_1(2)
- 'Debug #Debug_ , "Name_device=>" ; Name_device
- Print #Debug_ , "Name_device=>" ; Name_device
- '-------------------------------------------------------------------------------------------
- Case uart1G2_c_2: 'temperatura
- Debug #Debug_ , "jestem w command 2, case 2 "
- '-------------------------------------------------------------------------------------------
- Case uart1G2_c_3:
- Debug #Debug_ , "jestem w command 2, case 5 " ' diag_on
- 'Print "200,diag_on" 'flagi.2 = 1
- '-------------------------------------------------------------------------------------------
- Case uart1G2_c_4:
- Debug #Debug_ , "jestem w command 2, case 6 " 'diag_off
- 'Print "200,diag_off" 'flagi.2 = 0
- '-------------------------------------------------------------------------------------------
- Case uart1G2_c_5:
- Debug #Debug_ , "jestem w command 2, case 7 " 'rs_term_on
- 'Print "rs_term_on" 'Term_enable = 1
- '-------------------------------------------------------------------------------------------
- Case uart1G2_c_6:
- Debug #Debug_ , "jestem w command 2, case 8 " 'rs_term_off
- 'Print "rs_term_off" 'Term_enable = 0
- '-------------------------------------------------------------------------------------------
- Case uart1G2_c_7:
- Debug #Debug_ , "jestem w command 2, case 9 " 'rs_term_off
- 'print "podaj adres nowy adres: "
- 'Rs485_adres = Val(getcommands_1(3))
- 'Writeeeprom rs485_adres , &H10 '_ee , &H10 'writeeeprom Rs485_adres_ee
- 'Start Watchdog
- '-------------------------------------------------------------------------------------------
- Case Reboot:
- 'zrestartój system
- 'Print
- 'Print "Device will now reboot"
- 'Start Watchdog
- 'do
- 'loop
- Case bootloader: 'load
- 'disable interrupts
- 'Config Watchdog = 1024
- 'Start Watchdog
- 'do
- 'loop
- Case Help : '?
- 'wysietl komendy
- ' Print chr(10) ; "Ekoder absolutny SP9DR"
- ' Print "Version: " ; Version(2)
- ' Print "RS_485 Adres= " ; Rs485_adres
- ' print "120 Ohm terminacja = " ; Term_enable
- ' if Portc.5 = 1 then
- ' print "Wlaczona"
- ' else
- ' print "Wylaczona"
- ' end if
- 'print chr(10) ; " lista komend: "
- 'print "a------------Podaj azymut"
- 'print "t------------Podaj temperature"
- 'print "c------------Wolne"
- 'print "s------------Predkosc"
- 'print "diag_on------Diagnostyka wlacz" 'magnitude diagnostic
- 'print "diag_off-----Diagnostyka wylacz"
- 'print "rs_term_on---Terminacja wlacz"
- 'print "rs_term_off--Terminacja wylacz"
- 'print "reboot ------Restart systemu"
- 'print "load---------Aktualizuj oprogramowanie"
- 'print "adrr---------Zmiana adresu RS485"
- 'print "?------------Wyswielt liste komend"
- Case Else
- 'ponizej NIE USUWAJ TO JEST WAZNE!
- 'jak komenda nie rozpoznana zrób to
- 'Print #Debug_ , Prompt ; " " ; Uart_command_1 ; " " ; Notincommands
- 'Print #Debug_ , Prompt
- Getcommands_1(1) = ""
- Getcommands_1(2) = ""
- Getcommands_1(3) = ""
- End Select
- 'ponizej NIE USUWAJ TO JEST WAZNE!
- 'jak komenda nei rozpoznana zrób to
- Getcommands_1(1) = ""
- Getcommands_1(2) = ""
- Getcommands_1(3) = ""
- Case Broadcast: '255 broadcast do wszystkich
- 'Select Case Getcommands(2)
- ' Case Reboot:
- ' 'zrestartój system
- ' Print
- ' Print "Device will now reboot"
- ' Start Watchdog
- ' Case Help : '?
- ' Waitms Rs485_adres
- ' Print "Wind speed board ver: " ; Version(2)
- ' Print "RS_485 Adres= " ; Rs485_adres
- ' Case Else
- ' 'Print Prompt ; " " ; Uart_command ; " " ; Notincommands
- ' 'Print Prompt
- ' Getcommands(1) = ""
- ' Getcommands(2) = ""
- ' Getcommands(3) = ""
- ' End Select
- ' Getcommands(1) = ""
- ' Getcommands(2) = ""
- ' Getcommands(3) = ""
- Case Else
- 'ponizej NIE USUWAJ TO JEST WAZNE!
- Debug #Debug_ , "odebrlem zly adres "
- 'Print #Debug_ , Prompt ; " " ; Uart_command_1 ; " " ; Notincommands
- 'Print Prompt
- 'Jelsi zly adres wyczysc wszytkie komorki z odebranymi danymi
- Getcommands_1(1) = ""
- Getcommands_1(2) = ""
- Getcommands_1(3) = ""
- End Select
- 'ponizej NIE USUWAJ TO JEST WAZNE!
- 'jak komenda nei rozpoznana zrób to
- Getcommands_1(1) = ""
- Getcommands_1(2) = ""
- Getcommands_1(3) = ""
- '##########################################################
- End Sub
pozdrawiam Jacek.