?? serialport.java
字號(hào):
import java.lang.*;
/*
This serial class is for you to communicate through the radio modems.
Some details you should remember:
1) the baud rate set up for the modems is 115200 (that is choice 5)
2) the port you specify should be either 1 (COM1), which is the serial
port we ordinarily use to communicate with the robot; or more correctly
port 4 (COM4), which is where the pcmcia serial port is placed that you
will be plugging the radio modem into!
3) When both radio modems are on (green lights continuous), then you
are ready to establish a link. From either modem (the other one
doesn't even need to be plugged into a computer), you need to
type "wms1" (not the quotes, just the stuff inside the quotes), then
hit return. The way to do this is to send the following bytes
to the radio modem: 119 , 109 , 115 , 49 , 13. Once you do this,
the steady red light should light up on both modems and they're in data
mode. Don't forget to read all the echo characters off using read-byte
before you start using the comm link. enjoy.
4) Do NOT send the character 124 ('|') across the radio modems. It is a
control, escape character if you send it 3 times in a row, followed
by the return key.
*/
public class serialPort extends java.lang.Object
{
// open serial port at specified baud with other appropriate parameters.
// returns:
// 0 on success
// -1 on failure to open serial port
// -2 on failure to read port state
// -3 on failure to set port state
// coms are: 1 = "COM1"; 2 = "COM2" et cetera
// baud rates are: 1 = 9600; 2=19200; 3=38400; 4=57600; 5=115200; 6=230400
public native int openSerial(int comNum, int baudSpec);
public native int closeSerial();
// returns 0 on success or -1 on failure to send byte
public synchronized native int sendByte(int theByte);
// initialTimeout is measured in milliseconds //
// returns -6 on failure to set timeout, 0 on success
public synchronized native int setReadTimeout(int initialTimeout);
// returns -1 in error or timeout, else returns int between 0 and 255
public synchronized native int readByte();
static {
System.loadLibrary("sserial");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -