1114
i'm looking at the disassembly around the ioctl calls using gdb.
the object actually has debugging symbols, so functions are named.
it looks like ioctl is called by passing arguments on registers (fastcall?) here. the first argument is in edi, fd 13. esi, edx, and eax are also set.
i'll look up the value for TCGETS in my include files to deduce which register is the second argument for sure.
1116
it turns out esi is the second parameter. here it's TIOCCBRK, so i've actually missed the section of code I wanted to inspect, this run.
1118
1128
looping and catching ioctls with gdb, i'm seeing it differently from the strace. I see TIOCCBRK, then TCFLSH, then TIOCMBIS , but no TCGETS nor TCSETS .
when I straced I had to pass -f, maybe I have to get gdb to follow forks too. additionally, I could try restarting the process, it's kind of deep in loops.
1130
set follow-fork-mode parent|child|ask
break ioctl
commands 1
p/x $edi
p/x $esi
1133
it seems strange to me that more ioctls do not show in gdb. I wonder where they are hiding. anyway, I can use strace.
1135
1138
the unabbreviated unellided strace seems nice to me.
reviewing the complete ioctls I don't actually see any changes made to the serial. the data set is the same as the data retrieved.
I could find where it is set from the strace and figure out what it's ensuring but it probably makes sense to dive into the communication bytes for now.
1140
1157
I manually started handshaking with the flashing protocol in python :)
import os
# wait for device connection, only provides serial port briefly
while True:
try:
fd = os.open('/dev/ttyACM0', os.O_RDWR|os.O_NOCTTY)
break
except FileNotFoundError:
continue
# connected, handshake
os.write(fd, b'\xa0')
print(os.read(fd, 5)) # prints b'READY'