• 星瞳实验室APP,快速收到回复。扫描二维码或者点击 https://singtown.com/app/
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 每一个新的提问,单独发一个新帖子
  • 描述一定要详细 描述一定要详细 描述一定要详细
  • 请贴出具体的的目的,就是你要做什么。
  • 请贴出具体的代码,与报错提示
  • 代码一定要让别人可以运行的文本,不要贴图片
  • python中应该如何判断接收到的字符串是发送的字符串?



    • UART Control

      This example shows how to use the serial port on your OpenMV Cam. Attach pin

      P4 to the serial input of a serial LCD screen to see "Hello World!" printed

      on the serial LCD display.

      import time
      from pyb import UART

      Always pass UART 3 for the UART number for your OpenMV Cam.

      The second argument is the UART baud rate. For a more advanced UART control

      example see the BLE-Shield driver.

      uart = UART(3, 19200, timeout_char=1000)

      while(True):
      if uart.any():
      a = uart.readline()
      if a == "OK\r\n"
      sensor.snapshot().save("example1.jpg")
      我是要用32串口发送个字符串“OK\r\n”,在python中判断接收到的字符串,然后拍照储存到SD卡。



    • 你的if那一行,没有冒号吧



    • 缩进也不对吧……



    • @5ewopython中应该如何判断接收到的字符串是发送的字符串? 中说:

      额,我缩进了4个空格,可能粘贴上去就没了,冒号是没加。但是还是不行,我记得例程中说还要复位一下,是不是必须这样。



    • 代码格式问题
      来自星瞳实验室APP: 必看[视频]:玩转星瞳论坛 https://forum.singtown.com/topic/57

      请贴完整的代码,以及报错提示。



    • # UART Control
      #
      # This example shows how to use the serial port on your OpenMV Cam. Attach pin
      # P4 to the serial input of a serial LCD screen to see "Hello World!" printed
      # on the serial LCD display.
      
      import time
      from pyb import UART
      
      # Always pass UART 3 for the UART number for your OpenMV Cam.
      # The second argument is the UART baud rate. For a more advanced UART control
      # example see the BLE-Shield driver.
      uart = UART(3, 19200, timeout_char=1000)
      
      while(True):
          if uart.any():
              a = uart.readline().decode()
              print(a)
              if a == "OK\r\n":
                  sensor.snapshot().save("example1.jpg")
      

      0_1543926562881_错误.PNG

      Traceback (most recent call last):
      File "", line 17, in
      UnicodeError:
      MicroPython v1.9.4-4510-g23e8457de on 2018-06-29; OPENMV3 with STM32F765
      Type "help()" for more information.



    • 你最后一句的缩进是错的。



    • # UART Control
      #
      # This example shows how to use the serial port on your OpenMV Cam. Attach pin
      # P4 to the serial input of a serial LCD screen to see "Hello World!" printed
      # on the serial LCD display.
      
      import sensor,image
      from pyb import UART
      
      # Always pass UART 3 for the UART number for your OpenMV Cam.
      # The second argument is the UART baud rate. For a more advanced UART control
      # example see the BLE-Shield driver.
      uart = UART(3, 9600, timeout_char=1000)
      
      while(True):
          if uart.any():
              a = uart.readline().decode()
              print(a)
              if a == "OK\r\n":
                  print("You're on camera!")
                  img = sensor.snapshot()
                  img.morph(1, [+2, +1, +0,\
                                +1, +1, -1,\
                                +0, -1, -2])
                  img.save("example.jpg")
                  print("Done! Reset the camera to see the saved image.")
      

      我不知道怎么缩进,我是对照例程改的。

      Traceback (most recent call last):
      File "", line 21, in
      RuntimeError: Sensor Timeout!!
      MicroPython v1.9.4-4510-g23e8457de on 2018-06-29; OPENMV3 with STM32F765
      Type "help()" for more information.

      现在又不行了。



    • 新的问题,单独新发帖子。



    • 行,我先看看,不懂再发,感谢你!