Python Forum
send hexadecimal package variable UART
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
send hexadecimal package variable UART
#1
Smile 
Hello , guys
i am new using python i would like to send a package of hexadecimal values using the uart the problem it is two of the values are variables i have done a lot of research and i cant find anything it will be really helpful here is my code basically i am trying to send this

Output:
x = b'\x41\x0A\x01\variable\variable'
contition=True
while contition:
  main_input  = int(input("select a number: "))

  if main_input == 13:
   contition == False
   break

  elif main_input == 1:
    light_val = int(input("insert the new threshold value: "))
    a = (1, 10, light_val)
    csum = sum(a)
    csum = hex( csum^ 0xFF)
    print(csum)
    b = hex(light_val)
    c = hex(10)
    d = hex(1)
    e = hex(65)
    y = (e, c, d, b, csum) 
    x = b'\x41\x0A\x01\x05\EF'
    
    #ser.write(x)
    #ser.write(Y)
    print(Y)
  else:
    print(" Not Valid choice")
thanks a lot
Larz60+ write Oct-30-2020, 02:33 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

fixed for you this time. Please use tags on future posts.
Reply


Messages In This Thread
send hexadecimal package variable UART - by santos20 - Oct-30-2020, 01:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  UART write binary code trix 3 305 Apr-28-2024, 04:57 PM
Last Post: deanhystad
  UART & I2C slow down a loop trix 4 660 Dec-28-2023, 05:14 PM
Last Post: trix
  How to clean UART string Joni_Engr 4 2,541 Dec-03-2021, 05:58 PM
Last Post: deanhystad
  checking for valid hexadecimal digits Skaperen 3 6,480 Sep-02-2021, 07:22 AM
Last Post: buran
  UART Serial Read & Write to MP3 Player Doesn't Work bill_z 15 5,920 Jul-17-2021, 04:19 PM
Last Post: bill_z
  wrong data reading on uart fahri 6 3,421 Sep-29-2020, 03:07 PM
Last Post: Larz60+
  decimal or hexadecimal digits to int Skaperen 3 4,213 Sep-26-2017, 07:03 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020