code: def write(self, buf):
          
          self.check_pyb()
          try:
              return self.pyb.serial.write(buf)
          except (serial.serialutil.SerialException, BrokenPipeError, TypeError):
              # Write failed - assume that we got disconnected
              self.close()
              raise DeviceError('{} closed'.format(self.dev_name_short))
docs: Writes data to the pyboard over the serial port.