Ejemplo n.º 1
0
async def test_start():
    global station, infos, muxs, sim, timeout
    infos = tu.Infos()
    muxs = TestMuxs()
    sim = su.LgwSimServer()
    await infos.start_server()
    await muxs.start_server()
    await sim.start_server()

    station_args = ['station', '-p', '--temp', '.']
    station = await subprocess.create_subprocess_exec(*station_args)

    asyncio.ensure_future(timeout())
    with open("./gps.fifo", "wb", 0) as f:
        # Send an NMEA sentence every 1sec
        # These are not used to sync time in any way - they are only indicative of
        # having a fix and being able to produce a PPS signal
        with open("./cmd.fifo", "wb", 0) as c:
            await asyncio.sleep(1.0)
            for i in range(30):
                print('Writing GPGGA...')
                fixquality = (i & 4) * 2  # 4x 0 then 4x 2
                f.write(
                    nmea_cksum(
                        b'GPGGA,165848.000,4714.7671,N,00849.8387,E,%d,9,1.01,480.0,M,48.0,M,0000,0000'
                        % fixquality))
                print('Writing cmd.fifo...')
                c.write(b'{"msgtype":"alarm","text":"CMD test no.%d"}\n' %
                        (i, ))
                await asyncio.sleep(1)
    if muxs.tscnt > 0:
        await muxs.testDone(0)

    print('No 2nd volley of timesync messages')
    await muxs.testDone(1)
Ejemplo n.º 2
0
async def start_tcsim():
    global infos
    global muxs
    infos = tu.Infos(muxsuri=('ws://localhost:6039/router'))
    muxs = ExampleMuxs()
    await infos.start_server()
    await muxs.start_server()
Ejemplo n.º 3
0
async def test_start():
    global station, infos, muxs, cups, sim
    if not os.path.isfile("prep.done"):
        logger.warning("Expected file structure not there. Runing prep.sh.")
        prep = await subprocess.create_subprocess_exec("./prep.sh")
        ret = await prep.wait()
        if ret is not 0:
            logger.debug("Prep.sh script exited with error code: %d. Stopping",
                         ret)
            os._exit(1)
    sim = TestLgwSimServer(path='shome/spidev')
    infos = tu.Infos(muxsuri=('wss://localhost:6039/router'),
                     homedir='tc-0',
                     tlsidentity='infos-0')
    muxs = TestMuxs(homedir='tc-0', tlsidentity='muxs-0')
    cups0 = TestCups(homedir='cups-0', tlsidentity='cups-0')
    cups1 = TestCups(homedir='cups-1', tlsidentity='cups-1', tcdir='tc-0')
    cups1.port = 6041
    await sim.start_server()
    await infos.start_server()
    await muxs.start_server()
    await cups0.start_server()
    await cups1.start_server()
    if len(sys.argv) > 1 and sys.argv[1] == "runstation":
        await asyncio.sleep(0.3)  # give python some time to start up
        muxs.restart_station_handle = asyncio.ensure_future(
            muxs.restart_station())
Ejemplo n.º 4
0
async def test_start():
    global station, infos, muxs, sim, timeout
    infos = tu.Infos()
    muxs = TestMuxs()
    sim = su.LgwSimServer()
    await infos.start_server()
    await muxs.start_server()
    await sim.start_server()

    station_args = ['station', '-p', '--temp', '.']
    station = await subprocess.create_subprocess_exec(*station_args)

    asyncio.ensure_future(timeout())
    with open("./gps.fifo", "wb", 0) as f:
        with open("./cmd.fifo", "wb", 0) as c:
            await asyncio.sleep(1.0)
            for i in range(20):
                logger.debug('Writing GPGGA...')
                fixquality = (i & 4) * 2  # 4x 0 then 4x 2
                lat = b'00849.8387' if i & 1 else b'00848.8387'
                f.write(
                    nmea_cksum(
                        b'GPGGA,165848.000,4714.7671,N,%s,E,%d,9,1.01,480.0,M,48.0,M,0000,0000'
                        % (lat, fixquality)))
                logger.debug('Writing cmd.fifo...')
                c.write(b'{"msgtype":"alarm","text":"CMD test no.%d"}\n' %
                        (i, ))
                await asyncio.sleep(1)
    notok = 1
    logger.debug('gpscnt=%d gpsmove=%d gpsnofix=%d cmdcnt=%d' %
                 (muxs.gpscnt, muxs.gpsmove, muxs.gpsnofix, muxs.cmdcnt))
    if muxs.gpscnt >= 1 and muxs.gpsmove >= 1 and muxs.gpsnofix >= 1 and muxs.cmdcnt >= 15:
        notok = 0
    await muxs.testDone(notok)
Ejemplo n.º 5
0
async def start_tcsim():
    global infos
    global muxs
    infos = tu.Infos(muxsuri=('%s://localhost:6039/router' % ws),
                     tlsidentity=('infos-0' if tls_mode else None),
                     tls_no_ca=tls_no_ca)
    muxs = ExampleMuxs(tlsidentity=('muxs-0' if tls_mode else None),
                       tls_no_ca=tls_no_ca)
    await infos.start_server()
    await muxs.start_server()
Ejemplo n.º 6
0
async def test_start():
    global station, infos, muxs, sim
    infos = tu.Infos()
    muxs = TestMuxs()
    sim = TestLgwSimServer()

    await infos.start_server()
    await muxs.start_server()
    await sim.start_server()

    # 'valgrind', '--leak-check=full',
    station_args = ['station','-p', '--temp', '.']
    station = await subprocess.create_subprocess_exec(*station_args)
Ejemplo n.º 7
0
async def test_start():
    global station, infos, muxs
    infos = tu.Infos()
    muxs = TestMuxs()
    sim = su.LgwSimServer()
    await infos.start_server()
    await muxs.start_server()
    await sim.start_server()

    station_args = ['station', '-p', '--temp', '.']
    station = await subprocess.create_subprocess_exec(*station_args)

    asyncio.ensure_future(timeout())
Ejemplo n.º 8
0
async def test_start():
    global station, infos, muxs, sim
    infos = tu.Infos(muxsuri=('%s://localhost:6039/router' % ws),
                     tlsidentity=('infos-0' if tls_mode else None),
                     tls_no_ca=tls_no_ca)
    muxs = TestMuxs(tlsidentity=('muxs-0' if tls_mode else None),
                    tls_no_ca=tls_no_ca)
    sim = TestLgwSimServer()

    await infos.start_server()
    await muxs.start_server()
    await sim.start_server()

    # 'valgrind', '--leak-check=full',
    station_args = ['station', '-p', '--temp', '.']
    station = await subprocess.create_subprocess_exec(*station_args)
Ejemplo n.º 9
0
async def test_start():
    global station, infos, muxs, cups, sim
    sim = TestLgwSimServer()
    infos = tu.Infos(muxsuri = ('ws%s://localhost:6039/router' % isTLS),
                     homedir = '_tc',
                     tlsidentity = ('infos-0' if tls_mode else None),
                     tls_no_ca = tls_no_ca)
    muxs = TestMuxs(homedir = '_tc',
                    tlsidentity = ('muxs-0' if tls_mode else None),
                    tls_no_ca = tls_no_ca)
    cups = TestCups(homedir = '_cups', tcdir = '_tc',
                    tlsidentity = ('cups-0' if tls_mode else None),
                    tls_no_ca = tls_no_ca)
    cups2 = TestCups(homedir = '_cups', tcdir = '_tc', tlsidentity=None)
    cups2.port = 6041
    await sim.start_server()
    await infos.start_server()
    await muxs.start_server()
    await cups.start_server()
    await cups2.start_server()
    await asyncio.sleep(0.3)    # give python some time to start up
    muxs.restart_station_handle = asyncio.ensure_future(muxs.restart_station())