[R] problem reading from serial connection since 2.10.0

Tom Gottfried tom.gottfried at wzw.tum.de
Tue Dec 29 14:25:48 CET 2009


Dear list,

I have a balance connected to the serial port of a windows machine ("COM1") and I read the text
output of the balance with

scan("COM1", what="character", sep="\n", n=1)

after calling the previous line I press the print key on the balance which triggers sending one line
of text to the serial connection and with R 2.9.2 I get something like

Read 1 item
"+  32.004 mg"

Now with R 2.10.1 (and previously with 2.10.0) I have to press the print key on the balance twice to
get the same result, thus apparently I have to send two lines of text to make scan() reading only
one. But this is only when reading from the serial port, not when reading from a text file on disk.
The same is true for 2.10.1 on Linux (I did not try 2.9.2 nor 2.10.0 on Linux).
I can't figure out from the documentation nor the NEWS whether something should be specified
differently when calling scan since 2.10.0. Any ideas what this behaviour comes from?

Here the sessionInfo() for the three cases I have tested:
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets
[6] methods   base

respectively:

R version 2.10.1 (2009-12-14)
i386-pc-mingw32

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

respectively:
R version 2.10.1 (2009-12-14)
x86_64-unknown-linux-gnu

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8
 [5] LC_MONETARY=C              LC_MESSAGES=de_DE.UTF-8
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     methods   base

other attached packages:
[1] lattice_0.17-26 RODBC_1.3-1

loaded via a namespace (and not attached):
[1] grid_2.10.1

Thanks a lot!
Tom




More information about the R-help mailing list