Beispiel #1
0
 /**
  * Set events mask. Required flags shall be sent to the input. Variables with prefix
  * <b>"MASK_"</b>, shall be used as flags, for example <b>"MASK_RXCHAR"</b>. Sent parameter "mask"
  * is additive value, so addition of flags is allowed. For example if messages about data receipt
  * and CTS and DSR status changing shall be received, it is required to set the mask -
  * <b>"MASK_RXCHAR | MASK_CTS | MASK_DSR"</b>
  *
  * @return If the operation is successfully completed, the method returns true, otherwise false
  * @throws SerialPortException
  */
 public boolean setEventsMask(int mask) throws SerialPortException {
   checkPortOpened("setEventsMask()");
   if (SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX
       || SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS
       || SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X) { // since 0.9.0
     linuxMask = mask;
     if (mask > 0) {
       maskAssigned = true;
     } else {
       maskAssigned = false;
     }
     return true;
   }
   boolean returnValue = serialInterface.setEventsMask(portHandle, mask);
   if (!returnValue) {
     throw new SerialPortException(
         portName, "setEventsMask()", SerialPortException.TYPE_CANT_SET_MASK);
   }
   if (mask > 0) {
     maskAssigned = true;
   } else {
     maskAssigned = false;
   }
   return returnValue;
 }