Modified version of an exact read taken from the stk500 library. This version spawns another process to do the read from the serial device and blocks in receive. If the timeout is reached before the exact number of bytes is read (the default is infinity), any accumulated buffer is thrown away and an error is returned.
The functions manipulating the terminal attribute state do not read or write from the serial device anymore. Funs now take the termios as an argument. The termios must be retrieved and set using tcgetattr/1 and tcsetattr/3.