From c7e275f2214cff86fa98da9a12c92b685351aad5 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sat, 3 May 2025 08:58:39 +0800 Subject: Get template count. --- fpm.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'fpm.c') diff --git a/fpm.c b/fpm.c index 41a106c..e157698 100644 --- a/fpm.c +++ b/fpm.c @@ -178,12 +178,30 @@ uint8_t fpm_setpwd(uint32_t pwd) uint8_t buf[MAXPDLEN]; buf[0] = 0x12; - buf[1] = (uint8_t)((uint32_t)pwd >> 24); - buf[2] = (uint8_t)((uint32_t)pwd >> 16); - buf[3] = (uint8_t)((uint32_t)pwd >> 8); - buf[4] = (uint8_t)((uint32_t)pwd & 0xFF); + buf[1] = (uint8_t)(pwd >> 24); + buf[2] = (uint8_t)(pwd >> 16); + buf[3] = (uint8_t)(pwd >> 8); + buf[4] = (uint8_t)(pwd & 0xFF); send(0x01, buf, 5); recv(buf, &n); return buf[0] == OK; } + +uint16_t fpm_getcount(void) +{ + uint16_t n, count; + uint8_t buf[MAXPDLEN]; + + buf[0] = 0x1D; + send(0x01, buf, 1); + recv(buf, &n); + + count = 0; + if (buf[0] == OK && n >= 2) { + count = buf[1]; + count <<= 8; + count |= buf[2]; + } + return count; +} -- cgit v1.2.3