diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-03 19:30:43 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-03 19:30:43 +0000 |
commit | 46bd2ba42d186a81d7ad7e4a55e03dd63b2d042f (patch) | |
tree | 21c25e277606d6a711029c8d9511f57983cbc23b /csocketevents.c | |
parent | 8f3c91e91b634adaca77dac6cf314445cceefc78 (diff) | |
download | libphidget21-upstream.tar.gz |
Imported Upstream version 2.1.8.20121218upstream
Diffstat (limited to 'csocketevents.c')
-rw-r--r-- | csocketevents.c | 81 |
1 files changed, 57 insertions, 24 deletions
diff --git a/csocketevents.c b/csocketevents.c index e1e32e1..85b840b 100644 --- a/csocketevents.c +++ b/csocketevents.c @@ -886,6 +886,17 @@ PWC_SETKEYS(LED) INC_KEYCOUNT(currentLimitEcho, -1) phid->currentLimitEcho = value; } + else if(KEYNAME("CurrentLimitIndexed")) + { + if(CHKINDEX(led.numLEDs, LED_MAXLEDS)) + { + GET_DOUBLE_VAL; + INC_KEYCOUNT(LED_CurrentLimit[index], PUNI_DBL) + phid->LED_CurrentLimit[index] = value; + } + else + ret = EPHIDGET_OUTOFBOUNDS; + } else{ PWC_BAD_SETTYPE(LED); } @@ -1181,46 +1192,68 @@ PWC_SETKEYS(RFID) } else if(KEYNAME("LastTag")) { - unsigned char tagData[5]; + char *endPtr; + CPhidgetRFID_Tag tag = {0}; + tag.protocol = (CPhidgetRFID_Protocol)strtol(state, &endPtr, 10); + strncpy(tag.tagString, endPtr+1, 25); + INC_KEYCOUNT(lastTagValid, PUNI_BOOL) - phid->lastTagValid = PTRUE; + if(tag.protocol != 0) + phid->lastTagValid = PTRUE; + else + phid->lastTagValid = PFALSE; - tagData[0] = (hexval(state[0])<<4)|hexval(state[1]); - tagData[1] = (hexval(state[2])<<4)|hexval(state[3]); - tagData[2] = (hexval(state[4])<<4)|hexval(state[5]); - tagData[3] = (hexval(state[6])<<4)|hexval(state[7]); - tagData[4] = (hexval(state[8])<<4)|hexval(state[9]); + if(tag.protocol == PHIDGET_RFID_PROTOCOL_EM4100) + { + tag.tagData[0] = (hexval(tag.tagString[0])<<4)|hexval(tag.tagString[1]); + tag.tagData[1] = (hexval(tag.tagString[2])<<4)|hexval(tag.tagString[3]); + tag.tagData[2] = (hexval(tag.tagString[4])<<4)|hexval(tag.tagString[5]); + tag.tagData[3] = (hexval(tag.tagString[6])<<4)|hexval(tag.tagString[7]); + tag.tagData[4] = (hexval(tag.tagString[8])<<4)|hexval(tag.tagString[9]); + } - memcpy(phid->lastTag, tagData, 5); + phid->lastTag = tag; } - else if(KEYNAME("Tag")) + else if(KEYNAME("Tag2")) { - unsigned char tagData[5]; - //always increment on tagPresent==PUNI_BOOL before setting it! + char *endPtr; + CPhidgetRFID_Tag tag = {0}; + tag.protocol = (CPhidgetRFID_Protocol)strtol(state, &endPtr, 10); + strncpy(tag.tagString, endPtr+1, 25); + INC_KEYCOUNT(tagPresent, PUNI_BOOL) - phid->tagPresent = 1; + phid->tagPresent = PTRUE; - tagData[0] = (hexval(state[0])<<4)|hexval(state[1]); - tagData[1] = (hexval(state[2])<<4)|hexval(state[3]); - tagData[2] = (hexval(state[4])<<4)|hexval(state[5]); - tagData[3] = (hexval(state[6])<<4)|hexval(state[7]); - tagData[4] = (hexval(state[8])<<4)|hexval(state[9]); + INC_KEYCOUNT(lastTagValid, PUNI_BOOL) + phid->lastTagValid = PTRUE; - FIRE(Tag, tagData); + if(tag.protocol == PHIDGET_RFID_PROTOCOL_EM4100) + { + tag.tagData[0] = (hexval(tag.tagString[0])<<4)|hexval(tag.tagString[1]); + tag.tagData[1] = (hexval(tag.tagString[2])<<4)|hexval(tag.tagString[3]); + tag.tagData[2] = (hexval(tag.tagString[4])<<4)|hexval(tag.tagString[5]); + tag.tagData[3] = (hexval(tag.tagString[6])<<4)|hexval(tag.tagString[7]); + tag.tagData[4] = (hexval(tag.tagString[8])<<4)|hexval(tag.tagString[9]); + FIRE(Tag, tag.tagData); + } + + FIRE(Tag2, tag.tagString, tag.protocol); - memcpy(phid->lastTag, tagData, 5); + phid->lastTag = tag; } - else if(KEYNAME("TagLoss")) + else if(KEYNAME("TagLoss2")) { - //always increment on tagPresent==PUNI_BOOL before setting it! INC_KEYCOUNT(tagPresent, PUNI_BOOL) - phid->tagPresent = 0; - FIRE(TagLost, phid->lastTag); + phid->tagPresent = PFALSE; + + if(phid->lastTag.protocol == PHIDGET_RFID_PROTOCOL_EM4100) + FIRE(TagLost, phid->lastTag.tagData); + FIRE(TagLost2, phid->lastTag.tagString, phid->lastTag.protocol); } else if(KEYNAME("TagState")) { GET_INT_VAL; - //always increment on tagPresent==PUNI_BOOL before setting it! + INC_KEYCOUNT(tagPresent, PUNI_BOOL) phid->tagPresent = value; } |