项目:wpilibj
文件:JaguarCANDriver.java
/**
* Start waiting for a message to be received from the CAN bus.
* @param messageID MessageID filter to specify what message ID to be expected.
* @param sem Semaphore that indicates that the receive call has completed.
* @param timeout Number of seconds to wait for the expected message.
* @return Data available Now... call complete
*/
public boolean receiveMessageStart(int messageID,Semaphore sem,double timeout) throws CANTimeoutException {
int retVal = 0;
IntByReference recvstatus = new IntByReference(0);
recvstatus.setValue(0);
retVal = receiveMessageStart_semFn.call4(messageID,sem.getPointer(),(int) (timeout * 1000.0),recvstatus.getPointer().address().toUWord().toPrimitive());
int statusValue = recvstatus.getValue();
recvstatus.free();
CANExceptionFactory.checkStatus(statusValue,messageID);
return retVal != 0;
}
private void acquireResources() throws SemaphoreException {
Enumeration e = resources.elements();
while (e.hasMoreElements()) {
Semaphore s = (Semaphore) e.nextElement();
s.takeMillis(500);
}
}
private void releaseResources() {
Enumeration e = resources.elements();
while (e.hasMoreElements()) {
Semaphore s = (Semaphore) e.nextElement();
try {
s.give();
} catch (final SemaphoreException se) {
}
}
}
项目:wpilib-java
文件:JaguarCANDriver.java
/**
* Start waiting for a message to be received from the CAN bus.
* @param messageID MessageID filter to specify what message ID to be expected.
* @param sem Semaphore that indicates that the receive call has completed.
* @param timeout Number of seconds to wait for the expected message.
* @return Data available Now... call complete
*/
public boolean receiveMessageStart(int messageID,messageID);
return retVal != 0;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。