Skip to content
Back to formatted view

Raw Message

Message-ID: <CAN8WEg2W8-mqoscnF=Qe1g5auQVgDTHoJnmmP=WpiyFO+yXTiw@mail.gmail.com>
Date: 2015-04-02T02:03:29Z
From: Adam Rountrey
Subject: Windows serial connection

Using Windows 8.1

I have an Arduino connected and I am trying to read from and write to a
serial connection using R.  The problem involves the reading.  I am able to
establish the connection using the following:

> system("mode COM4 baud=9600 parity=n data=8", show.output.on.console=T)
> a = file("COM4", open="r+",encoding="UTF8", blocking=F)

I am able to write to the connection using:

> writeOne = function(x){
>    cat(paste(x, "\n", sep=""), file = a)
> }
> writeOne("test")

I am able to read from the connection using:

b = readLines(a,n=1)

However, if I read the last line in the COM4 buffer, and the Arduino later
writes more to the buffer, I am unable to read it.  I only get
"character(0)".  The Arduino seems to be behaving okay, as I can read an
write using the Arduino Serial Monitor.  If after reaching this point, I
close the connection and open it again, I am able to read from COM4 again
(until I read a final value again).  Any ideas as to what might be going
one here?

Many thanks for any ideas.

	[[alternative HTML version deleted]]