Function in python

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’)

Is there any particular reason you think you might be missing something?

Hi, I am not sure because the program stuck and does not call the function when I run the program.

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.