Joni
(Engr)
September 1, 2021, 12:17pm
1
Hi,
I need to make a function in python so that when I call the function with the argument, it should send serial command but I am not sure if I am writing the function in my program in the right way. Is there anything missing ?
def function_cmd(cmd):
# Send command
ser.write(bytearray(str(cmd),‘ascii’))
# Read line
bs = ser.readline()
print(bs)
I need to call the function latter in the code
function_cmd(‘ALPHA0505’)
tjol
(Thomas Jollans)
September 1, 2021, 2:04pm
2
Is there any particular reason you think you might be missing something?
Joni
(Engr)
September 1, 2021, 2:07pm
3
Hi, I am not sure because the program stuck and does not call the function when I run the program.
LiamBeran
(Liam Beran)
September 1, 2021, 3:33pm
4
Hm weird i hope you find your solution
If your program gets stuck and does not call the function, then there is
a bug somewhere else in the program, not the function.