🤖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"

    Scheduled Pinned Locked Moved Modules
    1 Posts 1 Posters 573 Views 1 Watching
    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 Offline
      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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post