summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Stebel <bartoszstebel@gmail.com>2015-04-19 05:03:44 +0200
committerSergiusz 'q3k' BazaƄski <q3k@q3k.org>2015-08-31 22:48:36 +0200
commite04883e09f8aea5c21c0f438b6bdeae23f3972be (patch)
treebbdc0911035737e571920afbb585e9036e245b96
parent93f976357de46711217c1bfeca92063b82aca9f4 (diff)
downloaddoorman-e04883e09f8aea5c21c0f438b6bdeae23f3972be.tar.gz
doorman-e04883e09f8aea5c21c0f438b6bdeae23f3972be.tar.bz2
doorman-e04883e09f8aea5c21c0f438b6bdeae23f3972be.zip
gnuj
-rw-r--r--admin/lib/proto.py6
-rw-r--r--admin/options.py4
-rw-r--r--arduino/src/config.h2
-rw-r--r--arduino/src/doorman.ino3
-rw-r--r--arduino/src/pc.cpp5
-rw-r--r--arduino/src/rf.cpp3
6 files changed, 18 insertions, 5 deletions
diff --git a/admin/lib/proto.py b/admin/lib/proto.py
index 025dc99..16c0ae3 100644
--- a/admin/lib/proto.py
+++ b/admin/lib/proto.py
@@ -22,10 +22,14 @@ class Proto(object):
def send(self, command):
cmd = str(command) + '\n'
print cmd
- self.fd.write(cmd)
+ for i in cmd:
+ sleep(0.02)
+ self.fd.write(i)
def recv(self):
line = self.fd.readline()
print line
+ if line[0] != '$':
+ return self.recv()
cmd = Command.from_str(line)
if cmd.command == 'E':
raise RemoteException(cmd.hash, cmd.uid)
diff --git a/admin/options.py b/admin/options.py
index 6f6fc5f..5b63d32 100644
--- a/admin/options.py
+++ b/admin/options.py
@@ -1,4 +1,4 @@
-url = '/dev/ttyUSB6'
+url = '/dev/ttyACM1'
serial = dict(
baudrate = 19200,
timeout = 60,
@@ -21,4 +21,4 @@ hash_bytes = 64
mac_bytes = 64
-init_sleep = 5
+init_sleep = 3
diff --git a/arduino/src/config.h b/arduino/src/config.h
index 29b60c0..d941578 100644
--- a/arduino/src/config.h
+++ b/arduino/src/config.h
@@ -13,7 +13,7 @@
/** Size of stored hash. */
#define EMEM_HASH_SIZE (32)
/** Flag that indicates (if defined) verbose mode (for diagnostic) */
-//#define DEBUG 1
+#define DEBUG 1
/**
* Flag that indicates (if defined) keyboard simulation mode (for diagnostic).
* In this mode keyboard always return pin.
diff --git a/arduino/src/doorman.ino b/arduino/src/doorman.ino
index b240970..4cf4790 100644
--- a/arduino/src/doorman.ino
+++ b/arduino/src/doorman.ino
@@ -35,6 +35,9 @@ extern boolean pc_send_flag;
void setup() {
Serial.begin(19200);
keypad_init();
+ #ifdef DEBUG
+ Serial.println("Initializing NFC..");
+ #endif
rf_init();
pinMode(DOOR_CTRN, OUTPUT);
#ifdef DEBUG
diff --git a/arduino/src/pc.cpp b/arduino/src/pc.cpp
index 6d3dc97..5c8080c 100644
--- a/arduino/src/pc.cpp
+++ b/arduino/src/pc.cpp
@@ -22,12 +22,14 @@ extern unsigned char g_Hash[];
* @return Returns true if message was received, false otherwise.
*/
boolean pc_parse(){
+ //Serial.write('#');
static int pc_idx=0;
char in = 0; // for incoming serial data
// send data only when you receive data:
while (Serial.available() > 0) {
//read the incoming byte:
in = Serial.read();
+ //Serial.write(in);
if (in=='$') {
//Start condition
pc_idx=0;
@@ -258,6 +260,9 @@ void pc_comm(){
emem_print();
} else if (pc_bytes[1]=='G' || pc_bytes[1]=='g'){
pc_send_flag=true;
+#ifdef DEBUG
+ Serial.println("send flag true");
+#endif
} else {
#ifdef DEBUG
Serial.println("Unknown command");
diff --git a/arduino/src/rf.cpp b/arduino/src/rf.cpp
index 2f12c01..8a0c76e 100644
--- a/arduino/src/rf.cpp
+++ b/arduino/src/rf.cpp
@@ -12,6 +12,7 @@ Adafruit_PN532 rfid(3, 4);
void rf_init(void) {
rfid.begin();
#ifdef DEBUG
+ Serial.println("firm?");
uint32_t versiondata = rfid.getFirmwareVersion();
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
@@ -32,7 +33,7 @@ boolean rf_comm(unsigned long * p_rfid) {
uint8_t mifareLength;
success = rfid.readPassiveTargetID(PN532_MIFARE_ISO14443A,
- &mifareBytes[0], &mifareLength);
+ &mifareBytes[0], &mifareLength, 100);
if (success){
#ifdef DEBUG
Serial.print("RFID Tag: ");