|
9 | 9 | import cc.arduino.packages.discoverers.NetworkDiscovery;
|
10 | 10 |
|
11 | 11 | public class SerialManager {
|
12 |
| - static ISerialUser otherSerialUser = null; // If someone else uses the |
13 |
| - // serial port he can register |
14 |
| - // here so we can |
15 |
| - // request him to disconnect |
16 |
| - // when we need the serial port |
17 |
| - |
18 |
| - static Set<IProject> fProjects = new HashSet<>(); |
19 |
| - |
20 |
| - /** |
21 |
| - * This method is used to register a serial user. A serial user is alerted |
22 |
| - * when the serial port will be disconnected (for instance for a upload) The |
23 |
| - * serial user is requested to act appropriately Only 1 serial user can be |
24 |
| - * registered at a given time. No check is done. |
25 |
| - * |
26 |
| - * @param serialUser |
27 |
| - */ |
28 |
| - public static void registerSerialUser(ISerialUser serialUser) { |
29 |
| - otherSerialUser = serialUser; |
30 |
| - } |
31 |
| - |
32 |
| - /** |
33 |
| - * This method is to unregister a serial user. |
34 |
| - */ |
35 |
| - public static void UnRegisterSerialUser() { |
36 |
| - otherSerialUser = null; |
37 |
| - } |
38 |
| - |
39 |
| - public static boolean StopSerialMonitor(String mComPort) { |
40 |
| - if (otherSerialUser != null) { |
41 |
| - return otherSerialUser.PauzePort(mComPort); |
| 12 | + static ISerialUser otherSerialUser = null; // If someone else uses the |
| 13 | + // serial port he can register |
| 14 | + // here so we can |
| 15 | + // request him to disconnect |
| 16 | + // when we need the serial port |
| 17 | + |
| 18 | + static Set<IProject> fProjects = new HashSet<>(); |
| 19 | + |
| 20 | + /** |
| 21 | + * This method is used to register a serial user. A serial user is alerted |
| 22 | + * when the serial port will be disconnected (for instance for a upload) The |
| 23 | + * serial user is requested to act appropriately Only 1 serial user can be |
| 24 | + * registered at a given time. No check is done. |
| 25 | + * |
| 26 | + * @param serialUser |
| 27 | + */ |
| 28 | + public static void registerSerialUser(ISerialUser serialUser) { |
| 29 | + otherSerialUser = serialUser; |
42 | 30 | }
|
43 |
| - return false; |
44 |
| - } |
45 | 31 |
|
46 |
| - public static void StartSerialMonitor(String mComPort) { |
47 |
| - if (otherSerialUser != null) { |
48 |
| - otherSerialUser.ResumePort(mComPort); |
| 32 | + /** |
| 33 | + * This method is to unregister a serial user. |
| 34 | + */ |
| 35 | + public static void UnRegisterSerialUser() { |
| 36 | + otherSerialUser = null; |
49 | 37 | }
|
50 | 38 |
|
51 |
| - } |
52 |
| - |
53 |
| - public static String[] listComPorts() { |
54 |
| - List<String> serialList = Serial.list(); |
55 |
| - String[] outgoing = new String[serialList.size()]; |
56 |
| - serialList.toArray(outgoing); |
57 |
| - return outgoing; |
58 |
| - } |
59 |
| - |
60 |
| - @SuppressWarnings("nls") |
61 |
| - public static String[] listBaudRates() { |
62 |
| - |
63 |
| - String[] outgoing = { "921600", "460800", "230400", "115200", "57600", "38400", "31250", "28800", "19200", |
64 |
| - "14400", "9600", "4800", "2400", "1200", "300" }; |
65 |
| - return outgoing; |
66 |
| - } |
67 |
| - |
68 |
| - @SuppressWarnings("nls") |
69 |
| - public static String[] listLineEndings() { |
70 |
| - String[] outgoing = { "none", "CR", "NL", "CR/NL" }; |
71 |
| - return outgoing; |
72 |
| - } |
73 |
| - |
74 |
| - @SuppressWarnings("nls") |
75 |
| - public static String getLineEnding(int selectionIndex) { |
76 |
| - switch (selectionIndex) { |
77 |
| - default: |
78 |
| - case 0: |
79 |
| - return ""; |
80 |
| - case 1: |
81 |
| - return "\r"; |
82 |
| - case 2: |
83 |
| - return "\n"; |
84 |
| - case 3: |
85 |
| - return "\r\n"; |
| 39 | + public static boolean StopSerialMonitor(String mComPort) { |
| 40 | + if (otherSerialUser != null) { |
| 41 | + return otherSerialUser.PauzePort(mComPort); |
| 42 | + } |
| 43 | + return false; |
86 | 44 | }
|
87 |
| - } |
88 | 45 |
|
89 |
| - public static String[] listNetworkPorts() { |
90 |
| - return NetworkDiscovery.getList(); |
91 |
| - } |
| 46 | + public static void StartSerialMonitor(String mComPort) { |
| 47 | + if (otherSerialUser != null) { |
| 48 | + otherSerialUser.ResumePort(mComPort); |
| 49 | + } |
| 50 | + |
| 51 | + } |
| 52 | + |
| 53 | + public static String[] listComPorts() { |
| 54 | + List<String> serialList = Serial.list(); |
| 55 | + String[] outgoing = new String[serialList.size()]; |
| 56 | + serialList.toArray(outgoing); |
| 57 | + return outgoing; |
| 58 | + } |
| 59 | + |
| 60 | + @SuppressWarnings("nls") |
| 61 | + public static String[] listBaudRates() { |
| 62 | + |
| 63 | + String[] outgoing = { "921600", "460800", "230400", "115200", "76800", "57600", "38400", "31250", "28800", |
| 64 | + "19200", "14400", "9600", "4800", "2400", "1200", "300" }; |
| 65 | + return outgoing; |
| 66 | + } |
| 67 | + |
| 68 | + @SuppressWarnings("nls") |
| 69 | + public static String[] listLineEndings() { |
| 70 | + String[] outgoing = { "none", "CR", "NL", "CR/NL" }; |
| 71 | + return outgoing; |
| 72 | + } |
| 73 | + |
| 74 | + @SuppressWarnings("nls") |
| 75 | + public static String getLineEnding(int selectionIndex) { |
| 76 | + switch (selectionIndex) { |
| 77 | + default: |
| 78 | + case 0: |
| 79 | + return ""; |
| 80 | + case 1: |
| 81 | + return "\r"; |
| 82 | + case 2: |
| 83 | + return "\n"; |
| 84 | + case 3: |
| 85 | + return "\r\n"; |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + public static String[] listNetworkPorts() { |
| 90 | + return NetworkDiscovery.getList(); |
| 91 | + } |
92 | 92 | }
|
0 commit comments