@@ -307,11 +307,6 @@ func (h *hub) logAction(sl string) {
307307 }
308308}
309309
310- func (u * logWriter ) Write (p []byte ) (n int , err error ) {
311- u .onWrite (p )
312- return len (p ), nil
313- }
314-
315310func (h * hub ) memoryStats () {
316311 var memStats runtime.MemStats
317312 runtime .ReadMemStats (& memStats )
@@ -339,56 +334,3 @@ func (h *hub) garbageCollection() {
339334 h .broadcastSys <- []byte ("{\" gc\" :\" done\" }" )
340335 h .memoryStats ()
341336}
342-
343- func (h * hub ) spErr (err string ) {
344- h .broadcastSys <- []byte ("{\" Error\" : \" " + err + "\" }" )
345- }
346-
347- func (h * hub ) spClose (portname string ) {
348- if myport , ok := h .serialHub .FindPortByName (portname ); ok {
349- h .broadcastSys <- []byte ("Closing serial port " + portname )
350- myport .Close ()
351- } else {
352- h .spErr ("We could not find the serial port " + portname + " that you were trying to close." )
353- }
354- }
355-
356- func (h * hub ) spWrite (arg string ) {
357- // we will get a string of comXX asdf asdf asdf
358- //log.Println("Inside spWrite arg: " + arg)
359- arg = strings .TrimPrefix (arg , " " )
360- //log.Println("arg after trim: " + arg)
361- args := strings .SplitN (arg , " " , 3 )
362- if len (args ) != 3 {
363- errstr := "Could not parse send command: " + arg
364- //log.Println(errstr)
365- h .spErr (errstr )
366- return
367- }
368- bufferingMode := args [0 ]
369- portname := strings .Trim (args [1 ], " " )
370- data := args [2 ]
371-
372- //log.Println("The port to write to is:" + portname + "---")
373- //log.Println("The data is:" + data + "---")
374-
375- // See if we have this port open
376- port , ok := h .serialHub .FindPortByName (portname )
377- if ! ok {
378- // we couldn't find the port, so send err
379- h .spErr ("We could not find the serial port " + portname + " that you were trying to write to." )
380- return
381- }
382-
383- // see if bufferingMode is valid
384- switch bufferingMode {
385- case "send" , "sendnobuf" , "sendraw" :
386- // valid buffering mode, go ahead
387- default :
388- h .spErr ("Unsupported send command:" + args [0 ] + ". Please specify a valid one" )
389- return
390- }
391-
392- // send it to the write channel
393- port .Write (data , bufferingMode )
394- }
0 commit comments