🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    LAN-W5500 restarts instead of "TCP data receive"

    Modules
    1
    1
    22
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dennis78ac
      last edited by

      Currently I try to create a TCP-Modbus-Server with at Core V2.7 (firmware V.1.14.9) and a several years old "LAN W5500 base" with installed RS485 extension (I use only the RJ45 connector for the test). With a standard PC I can receive without any issues data of a holding register. With my program I can first of all establish a connection (with button B). It is also possible to ask for the data and display the available bytes at the TCP connection (with button A). But when I want to get the data (with button C) the system crashes and restarts automatically. I did not found any way to solve this problem. It tested "tcp_receive_packet" with 0 as argument as in the manual, but also with the amount of data bytes available. Has anyone an idea? This is the test code:

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import module
      import time
      
      setScreenColor(0x222222)
      Connected = None
      
      lan = module.get(module.LANBASE)
      LabelConnection = M5TextBox(30, 39, "No connection", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)
      label1 = M5TextBox(30, 121, "-", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)
      
      def buttonB_wasPressed():
        global Connected
        if Connected:
          Connected = False
          lan.socket_close()
          LabelConnection.setText('No connection')
        else:
          Connected = True
          lan.tcp_udp_config('192.168.179.13', 502, 1, 2)
          wait(2)
          LabelConnection.setText(str(lan.local_ip()))
      btnB.wasPressed(buttonB_wasPressed)
      
      def buttonA_wasPressed():
        global Connected
        label1.setText('-')
        lan.tcp_send_packet('\x00\x01\x00\x00\x00\x06\x01\x03\x75\x79\x00\x02')
        wait(2)
        label1.setText(str(lan.is_available_packet(1)))
      btnA.wasPressed(buttonA_wasPressed)
      
      def buttonC_wasPressed():
        global Connected
        label1.setText('-')
        lan.tcp_send_packet('\x00\x01\x00\x00\x00\x06\x01\x03\x75\x79\x00\x02')
        wait(2)
        label1.setText(str(lan.tcp_receive_packet(0)))
      btnC.wasPressed(buttonC_wasPressed)
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post