Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invelion Active Chip #107

Open
cfuent-es opened this issue Mar 7, 2023 · 1 comment
Open

Invelion Active Chip #107

cfuent-es opened this issue Mar 7, 2023 · 1 comment

Comments

@cfuent-es
Copy link

Hello everybody,

I have an Invelion device, and I wrote the following Python script to fetch the passages:

import time
import socket
from datetime import datetime

def receive_data(sock):
    buffer = sock.recv(1024 * 4)
    buffer = buffer.hex()
    messages = []
    while len(buffer) > 0:
        index = buffer.find("a0")
        if index == -1:
            break
        message = buffer[index:index+42]
        messages.append(message)
        buffer = buffer[index+42:]
    return messages

def process_message(message):
    chip_code = message[34:38].upper()
    now = datetime.fromtimestamp(time.time())
    now_str = now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
    file_name = chip_code + " " + now_str + ".txt"
    with open("passings/" + file_name, "a") as file:
        file.write(chip_code + " | " + now_str + "\n")
    file.close()

def client(host='192.168.0.178', port=4001):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (host, port)
    print("Connecting to %s port %s" % server_address)
    sock.connect(server_address)
    try:
        readings, second, sends = [], datetime.now().second, 0
        while True:
            message = "A006FF8B010001CE"
            sock.sendall(bytes.fromhex(message))
            sends += 1
            messages = receive_data(sock)
            for msg in messages:
                size = int(msg[2:4], 16)
                if(size == 19):
                    readings.append(msg)
                    process_message(msg)
            old_second = second
            second = datetime.now().second
            if second != old_second:
                print("Second: %d" % second, "Sends: %d" % sends, "Readings: %d" % len(readings))
                readings = []
                sends = 0
            #time.sleep(1)

    except socket.error as e:
        print("Socket error: %s" % str(e))
    except Exception as e:
        print("Other exception: %s" % str(e))
    finally:
        print("Closing connection to the server")
        sock.close()

client()

I would like to integrate with CrossMgr, perhaps saving passes directly to the pass database. What would be the best format to deliver these tickets?

Thanks.

@esitarski
Copy link
Owner

esitarski commented Mar 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants