As long as I'm replying to this, I see a few more issues to comment on: On Fri, Nov 13, 2015 at 12:20 PM, kent nyberg <k...@z-sverige.nu> wrote: > if place_to_read.closed: > print("Drive error. Drive closed.")
You probably also want to break or return here. Even better: raise an exception instead of printing. That said, why would this ever be closed here, since you just read from it two lines prior (which would have raised an exception if the file were closed), and you haven't closed it in the meantime? > if checkfirstbit(klar[RegisterAX]): > print("First bit is set. Move Cmd.") > if (klar[0] & 0b0111111111111111): > print("Cmd ERROR: Multiple commands is set.") Why do you pass the commands in a bit field if you're not going to allow multiple commands to be set? Also, see above about break/return/exception. > pass Unnecessary. > #Change RegisterAX offset+2bytes, > RegisterAX=+2 #We read two bytes per cycle. Becaus command is first, > and variables are second. This sets RegisterAX to 2. Specifically, positive 2. If you want to *add* 2, you probably meant to write: RegisterAX += 2 This also points out a good reason for using spaces around operators, as "RegisterAX =+ 2" would have caused a SyntaxError and been more easily detectable. -- https://mail.python.org/mailman/listinfo/python-list