+static int openpcd_get_api_version(struct rfid_reader_handle *rh, u_int8_t *version)
+{
+ int ret;
+
+ // preset version result to zero
+ rcv_hdr->val=0;
+
+ ret = openpcd_xcv(OPENPCD_CMD_GET_API_VERSION, 0, 0, 0, NULL);
+ if (ret < 0) {
+ DEBUGPC("ERROR sending command [%i]\n", ret);
+ return ret;
+ }
+
+ if (ret < sizeof(struct openpcd_hdr)) {
+ DEBUGPC("ERROR: short packet [%i]\n", ret);
+ return -EINVAL;
+ }
+
+ *version = rcv_hdr->val;
+
+ return ret;
+}
+
+static int openpcd_get_environment(struct rfid_reader_handle *rh,
+ unsigned char num_bytes,
+ unsigned char *buf)
+{
+ int ret;
+
+ DEBUGP(" ");
+
+ ret = openpcd_xcv(OPENPCD_CMD_GET_ENVIRONMENT, 0x00, num_bytes, 0, NULL);
+ if (ret < 0) {
+ DEBUGPC("ERROR sending command [%i]\n",ret);
+ return ret;
+ }
+ DEBUGPC("ret = %d\n", ret);
+
+ memcpy(buf, rcv_hdr->data, ret - sizeof(struct openpcd_hdr));
+ DEBUGPC("len=%d val=%s: OK\n", ret - sizeof(struct openpcd_hdr),
+ rfid_hexdump(rcv_hdr->data, ret - sizeof(struct openpcd_hdr)));
+
+ return ret;
+}
+
+static int openpcd_set_environment(struct rfid_reader_handle *rh,
+ unsigned char num_bytes,
+ const unsigned char *buf)
+{
+ int ret;
+
+ ret = openpcd_xcv(OPENPCD_CMD_SET_ENVIRONMENT, 0, 0, num_bytes, buf);
+ if (ret < 0) {
+ DEBUGPC("ERROR sending command [%i]\n",ret);
+ return ret;
+ }
+
+ if (ret < sizeof(struct openpcd_hdr)) {
+ DEBUGPC("ERROR: short packet [%i]\n", ret);
+ return -EINVAL;
+ }
+
+ return rcv_hdr->val;
+}
+
+static int openpcd_reset(struct rfid_reader_handle *rh)
+{
+ int ret;
+
+ DEBUGP("reset ");
+ ret = openpcd_xcv(OPENPCD_CMD_RESET, 0, 0, 0, 0);
+
+ return ret;
+}
+