1

I have a /dev/ttyUSB device and a /dev/ttyMFD device that I need to stream to logfiles. For the USB device I could use termios and configure it through that. This was pretty straight forward and there was a bit of documentation for this as well.

I can't seem to find any for the MFD though. Some places call it a MultiFuctionDevice and others call it the Medfield High Speed UART device. Which is correct in the first place?

And secondly, can I open it in the same way that I open up a regular ttyUSB device?

Here is the snippit I use to open USB devices.

int fd = open(USBDEVICE0, O_RDWR);


struct termios io;
memset(&io, 0, sizeof(io));

io.c_iflag = 0;
io.c_oflag = 0;
io.c_cflag = CS8|CREAD|CLOCAL;           // 8n1, see termios.h for more information
io.c_lflag = 0;

// TODO -- Since we are operating in non-blocking mode; confirm VMIN and VTIME settings have no effect on duration of the read() call.

io.c_cc[VMIN] = 1;
io.c_cc[VTIME] = 5;

speed_t speedSymbol = B921600;

cfsetospeed(&io, speedSymbol);
cfsetispeed(&io, speedSymbol);


int retVal;
retVal = tcsetattr(fd, TCSANOW, &io);

tcflush(fd, TCIOFLUSH);
usleep(100);

EDIT

For anyone who comes across this, there is one caveat. You must open the device in raw mode and dump everything into a log file. Parsing must be done post. Everything will come out as raw data but if you try to do any kind of configuration, the devices buffer will not be able to capture all the data, hold it, and process it in time before more data comes along.

Tropical_Peach
  • 1,143
  • 3
  • 16
  • 29

1 Answers1

2

MFD in Linux kernel is common abbreviation to Multi-Functional Device, Legacy serial driver for Edison abuses that and uses it's own interpretation as you mentioned: Medfield. In the upstream kernel the abbreviation MID is used regarding to Mobile Internet Device. In particular the serial driver is called drivers/tty/serial/8250_mid.c. See https://en.wikipedia.org/wiki/Mobile_Internet_device.

Yes, you may do the same operations as you did on top of /dev/ttyUSBx.

0andriy
  • 4,183
  • 1
  • 24
  • 37
  • For anyone who comes across this, there is one caveat. You must open the device in raw mode and dump everything into a log file. Parsing must be done post. – Tropical_Peach Dec 06 '16 at 15:24
  • @Tropical_Peach, don't quite get the second part. Why do you need log file? Raw mode is recommended when you are using UART for something else then usual tty. – 0andriy Dec 07 '16 at 23:10
  • I need a log file in my instance because I need to record all of the data that comes out of this MFD, the only way to get all of the data correctly was to record the data to a log file. – Tropical_Peach Dec 08 '16 at 14:48