eventgen.py

来自「MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis」· Python 代码 · 共 43 行

PY
43
字号
#!/usr/bin/python# This file is part of MANTIS OS, Operating System# See http://mantis.cs.colorado.edu/## Copyright (C) 2003-2005 University of Colorado, Boulder## This program is free software; you can redistribute it and/or# modify it under the terms of the mos license (see file LICENSE)import socket, struct, syssys.path.append('modules')import eventssys.path.pop()PORT = 1521HOST = '' # empty string meanslocalhost s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)def start_node(binary, id, x, y):    packstr = "!5i" + str(len(binary)) + "s"    data_size = 12 + len(binary)    pkt = struct.pack(packstr, data_size, events.NEW_NODE_EVENT, id, x, y, binary)    s.sendto(pkt, (HOST, PORT))id = 0x = 10y = 10for i in range(0, 3):    start_node('binaries/sense_forward_recv.elf', id, x, y)    id += 1    x += 1    y += 1start_node('binaries/sense_forward_send.elf', id, x, y)while 1:    time.sleep(1)s.close()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?