summaryrefslogtreecommitdiff
path: root/digital/avr/modules/twi/test/test_twi_host.py
blob: 5af0e669ce2f565482aa147b5ddfbf7635298769 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
sys.path.append (sys.path[0] + '/../../../../../host')

from mex.hub import Hub
from mex.msg import Msg
from mex.node import Node
from utils.forked import Forked

import os, signal, time

def log (x):
    print x

h = Hub (min_clients = 3, log = log)
fh = Forked (h.wait)

n = Node ()
def nf ():
    while True:
        time.sleep (1)
        n.wait (n.date + 1)
fn = Forked (nf)

slave = os.popen ('./test_twi_sl.host', 'w')

try:
    os.system ('./test_twi_master.host')
finally:
    fn.kill ()
    fh.kill ()
    slave.close ()
    time.sleep (1)