OSDN Git Service

lejos_NXJ_win32_0_5_0beta.zip
[nxt-jsp/lejos_nxj.git] / nxtOSEK / lejos_nxj / src / java / pccomms / lejos / pc / comm / NXTProtocol.java
1 package lejos.pc.comm;
2
3 public interface NXTProtocol {
4         // Command types constants. Indicates type of packet being sent or received.
5         public static byte DIRECT_COMMAND_REPLY = 0x00;
6         public static byte SYSTEM_COMMAND_REPLY = 0x01;
7         public static byte REPLY_COMMAND = 0x02;
8         public static byte DIRECT_COMMAND_NOREPLY = (byte)0x80; // Avoids ~100ms latency
9         public static byte SYSTEM_COMMAND_NOREPLY = (byte)0x81; // Avoids ~100ms latency
10         
11         // System Commands:
12         public static byte OPEN_READ = (byte)0x80;
13         public static byte OPEN_WRITE = (byte)0x81;
14         public static byte READ = (byte)0x82;
15         public static byte WRITE = (byte)0x83;
16         public static byte CLOSE = (byte)0x84;
17         public static byte DELETE = (byte)0x85;
18         public static byte FIND_FIRST = (byte)0x86;
19         public static byte FIND_NEXT = (byte)0x87;
20         public static byte GET_FIRMWARE_VERSION = (byte)0x88;
21         public static byte OPEN_WRITE_LINEAR = (byte)0x89;
22         public static byte OPEN_READ_LINEAR = (byte)0x8A;
23         public static byte OPEN_WRITE_DATA = (byte)0x8B;
24         public static byte OPEN_APPEND_DATA = (byte)0x8C;
25         // Many commands could be hidden between 0x8D and 0x96!
26         public static byte BOOT = (byte)0x97;
27         public static byte SET_BRICK_NAME = (byte)0x98;
28         // public static byte MYSTERY_COMMAND = (byte)0x99;
29         // public static byte MYSTERY_COMMAND = (byte)0x9A;
30         public static byte GET_DEVICE_INFO = (byte)0x9B;
31         // commands could be hidden here...
32         public static byte DELETE_USER_FLASH = (byte)0xA0;
33         public static byte POLL_LENGTH = (byte)0xA1;
34         public static byte POLL = (byte)0xA2;
35         
36         public static byte NXJ_FIND_FIRST = (byte)0xB6;
37         public static byte NXJ_FIND_NEXT = (byte)0xB7;
38         
39         // Poll constants:
40         public static byte POLL_BUFFER = (byte)0x00;
41         public static byte HIGH_SPEED_BUFFER = (byte)0x01;
42                 
43         // Direct Commands
44         public static byte START_PROGRAM = 0x00;
45         public static byte STOP_PROGRAM = 0x01;
46         public static byte PLAY_SOUND_FILE = 0x02;
47         public static byte PLAY_TONE = 0x03;
48         public static byte SET_OUTPUT_STATE = 0x04;
49         public static byte SET_INPUT_MODE = 0x05;
50         public static byte GET_OUTPUT_STATE = 0x06;
51         public static byte GET_INPUT_VALUES = 0x07;
52         public static byte RESET_SCALED_INPUT_VALUE = 0x08;
53         public static byte MESSAGE_WRITE = 0x09;
54         public static byte RESET_MOTOR_POSITION = 0x0A; 
55         public static byte GET_BATTERY_LEVEL = 0x0B;
56         public static byte STOP_SOUND_PLAYBACK = 0x0C;
57         public static byte KEEP_ALIVE = 0x0D;
58         public static byte LS_GET_STATUS = 0x0E;
59         public static byte LS_WRITE = 0x0F;
60         public static byte LS_READ = 0x10;
61         public static byte GET_CURRENT_PROGRAM_NAME = 0x11;
62         // public static byte MYSTERY_OPCODE = 0x12; // ????
63         public static byte MESSAGE_READ = 0x13;
64         // public static byte POSSIBLY_MORE_HIDDEN = 0x14; // ????
65         
66         // NXJ additions
67         public static byte NXJ_DISCONNECT = 0x20; 
68         public static byte NXJ_DEFRAG = 0x21;
69         
70         // Output state constants 
71         // "Mode":
72         /** Turn on the specified motor */
73         public static byte MOTORON = 0x01;
74         /** Use run/brake instead of run/float in PWM */
75         public static byte BRAKE = 0x02;
76         /** Turns on the regulation */
77         public static byte REGULATED = 0x04; 
78
79         // "Regulation Mode":
80         /** No regulation will be enabled */
81         public static byte REGULATION_MODE_IDLE = 0x00;
82         /** Power control will be enabled on specified output */
83         public static byte REGULATION_MODE_MOTOR_SPEED = 0x01;
84         /** Synchronization will be enabled (Needs enabled on two output) */
85         public static byte REGULATION_MODE_MOTOR_SYNC = 0x02; 
86
87         // "RunState":
88         /** Output will be idle */
89         public static byte MOTOR_RUN_STATE_IDLE = 0x00;
90         /** Output will ramp-up */
91         public static byte MOTOR_RUN_STATE_RAMPUP = 0x10;       
92         /** Output will be running */
93         public static byte MOTOR_RUN_STATE_RUNNING = 0x20; 
94         /** Output will ramp-down */
95         public static byte MOTOR_RUN_STATE_RAMPDOWN = 0x40;
96         
97         // Input Mode Constants
98         // "Port Type":
99         /**  */
100         public static byte NO_SENSOR = 0x00;
101         /**  */
102         public static byte SWITCH = 0x01;
103         /**  */
104         public static byte TEMPERATURE = 0x02;
105         /**  */
106         public static byte REFLECTION = 0x03;
107         /**  */
108         public static byte ANGLE = 0x04;
109         /**  */
110         public static byte LIGHT_ACTIVE = 0x05;
111         /**  */
112         public static byte LIGHT_INACTIVE = 0x06;
113         /**  */
114         public static byte SOUND_DB = 0x07;
115         /**  */
116         public static byte SOUND_DBA = 0x08;
117         /**  */
118         public static byte CUSTOM = 0x09;
119         /**  */
120         public static byte LOWSPEED = 0x0A;
121         /**  */
122         public static byte LOWSPEED_9V = 0x0B;
123         /**  */
124         public static byte NO_OF_SENSOR_TYPES = 0x0C;
125
126         // "Port Mode":
127         /**  */
128         public static byte RAWMODE = 0x00;
129         /**  */
130         public static byte BOOLEANMODE = 0x20;
131         /**  */
132         public static byte TRANSITIONCNTMODE = 0x40;
133         /**  */
134         public static byte PERIODCOUNTERMODE = 0x60;
135         /**  */
136         public static byte PCTFULLSCALEMODE = (byte)0x80;
137         /**  */
138         public static byte CELSIUSMODE = (byte)0xA0;
139         /**  */
140         public static byte FAHRENHEITMODE = (byte)0xC0;
141         /**  */
142         public static byte ANGLESTEPSMODE = (byte)0xE0;
143         /**  */
144         public static byte SLOPEMASK = 0x1F;
145         /**  */
146         public static byte MODEMASK = (byte)0xE0;
147 }
148