Function adas.adas_write_pipe

def adas_write_pipe(pipe, value)

Write a value to a bi-directional pipe.

Parameters

pipe : subprocess.Popen
pipe object

Returns

value : str, int, numpy.int64, float
The quantity to write into the pipe.

Notes

ADAS programs written in fortran communicate via bi-directional pipes connected to stdin. The routine takes the value of a limited number of types, converts these to bytes, writes to the pipe and then flushes the pipe.

The pipe must be setup and terminated in the calling program.

This routine works with python 2 and python 3.

Version History

  • Martin O'Mullane, 19-01-2014

    • First version
  • Martin O'Mullane, 05-10-2018

    • Raise an exception, rather than hanging, if the type of variable cannot be determined.
    • Import numpy for its types. The type of a single element of a numpy defined int array is numpy.int64 and not int. Testing the type with isinstance requires the type and not just the name.

Example

See run_adas208.py as an example of how to use this routine.