我尝试使用内存映射dev / mem /将消息写入硬件邮箱,但我发送的所有内容都会被发送两次。因此,在下面的代码中,将单个1发送到MBOX后,邮箱深度表示深度为2。 当我从邮箱中读取它有2个。知道为什么会这样吗?
with open("/dev/mem", "r+b") as mem_fd:
addr_p = mmap.mmap(mem_fd.fileno(), mem_size[UPROC_PIF_AREA], offset = mem_offsets[PROC_PIF_AREA])
#Sending the message header to register mbox_xt first
print "Sending message header"
packed_mbox_status = addr_p[MBOX_STATUS:MBOX_STATUS + 4]
mbox_to_microp_depth = struct.unpack("BBBB", packed_mbox_status)
print "mbox_to_microp_depth : " + str(mbox_to_microp_depth)
addr_p[MBOX_XT:MBOX_XT+4] = struct.pack("<L", 1)
packed_mbox_status = addr_p[MBOX_STATUS:MBOX_STATUS + 4]
mbox_to_microp_depth = struct.unpack("BBBB", packed_mbox_status)
print "mbox_to_microp_depth : " + str(mbox_to_microp_depth)