@@ -158,7 +158,7 @@ class Controller {
158158 // Adds the `listener` function to the end of the listeners array for the event named `eventName`.
159159 // @param {string } eventName The name of the event.
160160 // @param {function } listener The listener function.
161- on ( eventName , listener ) {
161+ addListener ( eventName , listener ) {
162162 const listeners = this . listeners [ eventName ] ;
163163 if ( ! listeners || typeof listener !== 'function' ) {
164164 return false ;
@@ -169,17 +169,20 @@ class Controller {
169169 // Removes the specified `listener` from the listener array for the event named `eventName`.
170170 // @param {string } eventName The name of the event.
171171 // @param {function } listener The listener function.
172- off ( eventName , listener ) {
172+ removeListener ( eventName , listener ) {
173173 const listeners = this . listeners [ eventName ] ;
174174 if ( ! listeners || typeof listener !== 'function' ) {
175175 return false ;
176176 }
177177 listeners . splice ( listeners . indexOf ( listener ) , 1 ) ;
178178 return true ;
179179 }
180- // @param {string } port
181- // @param {object } [options]
182- // @param {function } [callback]
180+ // Opens a connection to the given serial port.
181+ // @param {string } port The path of the serial port you want to open. For example, `dev/tty.XXX` on Mac and Linux, or `COM1` on Windows.
182+ // @param {object } [options] The options object.
183+ // @param {string } [options.controllerType] One of: 'Grbl', 'Smoothe', 'TinyG'. Defaults to 'Grbl'.
184+ // @param {number } [options.baudrate] Defaults to 115200.
185+ // @param {function } [callback] Called after a connection is opened.
183186 openPort ( port , options , callback ) {
184187 if ( typeof options !== 'object' ) {
185188 options = { } ;
@@ -190,17 +193,21 @@ class Controller {
190193 }
191194 this . socket && this . socket . emit ( 'open' , port , options , callback ) ;
192195 }
193- // @param {string } port
194- // @param {function } [callback]
196+ // Closes an open connection.
197+ // @param {string } port The path of the serial port you want to close. For example, `dev/tty.XXX` on Mac and Linux, or `COM1` on Windows.
198+ // @param {function } [callback] Called once a connection is closed.
195199 closePort ( port , callback ) {
196200 if ( typeof callback !== 'function' ) {
197201 callback = noop ;
198202 }
199203 this . socket && this . socket . emit ( 'close' , port , callback ) ;
200204 }
201- listPorts ( ) {
202- this . socket && this . socket . emit ( 'list' ) ;
205+ // Retrieves a list of available serial ports with metadata.
206+ // @param {function } [callback] Called once completed.
207+ listPorts ( callback ) {
208+ this . socket && this . socket . emit ( 'list' , callback ) ;
203209 }
210+ // Executes a command on the server.
204211 // @param {string } cmd The command string
205212 // @example Example Usage
206213 // - Load G-code
@@ -253,6 +260,7 @@ class Controller {
253260 }
254261 this . socket && this . socket . emit . apply ( this . socket , [ 'command' , port , cmd ] . concat ( args ) ) ;
255262 }
263+ // Writes data to the serial port.
256264 // @param {string } data The data to write.
257265 // @param {object } [context] The associated context information.
258266 write ( data , context ) {
@@ -262,6 +270,7 @@ class Controller {
262270 }
263271 this . socket && this . socket . emit ( 'write' , port , data , context ) ;
264272 }
273+ // Writes data and a newline character to the serial port.
265274 // @param {string } data The data to write.
266275 // @param {object } [context] The associated context information.
267276 writeln ( data , context ) {
0 commit comments