Java/Comunicazione seriale: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
sintassi colorata |
fix (modifico a sezioni |
||
Riga 116:
import javax.comm.*;
import java.util.*;
...
//
// Platform specific port name, here a Unix name
Riga 126:
// port, but instead make it user configurable.
//
String wantedPortName = "/dev/ttya";
//
// Get an enumeration of all ports known to JavaComm
//
Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers();
//
// Check each port identifier if
Riga 151:
System.err.println("Could not find serial port " + wantedPortName);
System.exit(1);
}
//
// Use port identifier for acquiring the port
Riga 248:
* Explain how to mix binary and character I/O over the same stream
* Fix the example to use streams}}
<source lang=comm>
// Write to the output
os.print("AT");
Riga 255:
is.readLine(); // First read will contain the echoed command you sent to it. In this case: "AT"
is.readLine(); // Second read will remove the extra line feed that AT generates as output
</source>
==== Simple Reading of Data (Polling) ====
|