Skip to content

Instantly share code, notes, and snippets.

@jontey
Created June 28, 2018 03:30
Show Gist options
  • Save jontey/25b2a3e015ed4e4eccc9ff530c13ad9d to your computer and use it in GitHub Desktop.
Save jontey/25b2a3e015ed4e4eccc9ff530c13ad9d to your computer and use it in GitHub Desktop.
Setup RFID reader on your local workstation

Requirements

  1. Python2.7

  2. Node.js + npm

Steps

  1. Clone the repository on your pc

  2. Run pip install -r requirements.txt

  3. Run npm install

  4. To run the script, use npm run start

    If it doesn't work, check package.json under the scripts section to see the run command.

  5. If the script is complaining about electron not installed, you might have to run npm install -g electron

Debugging

There are two parts you would have to debug. The Python script and the Node.js browser window.

Python Script

To debug this, you just need to run python rfid_reader.py with the RFID reader attached to your pc. Scan your badge and see what it returns. It should return a JSON object with {ok: true, ...} or {ok:false, ...}.

Most likely the problem is here, as the script interfaces between the USB reader and the server.

Node.js Browser Window

To debug this, you would can open the Dev Tools Ctrl + Alt + I. Then it would be like a normal Chrome browser with console.log.

If you don't want to have it open full screen by default you can turn it off somewhere in index.js or in the app folder.

If any changes were made to the AP server, it wouldn't affect this part as the python script provides that layer of abstraction already.

Debug this part if you want to change the display colors or show a time clock, or other GUI type stuff.

You need to be careful when following guides on the internet as some code runs in the browser and some on the Node.js side. The confusion arises because both sides uses JavaScript so you would need to understand which part of the script belongs where. With the Django app you wouldn't run into this issue as the server side script is in Python and the browser side is in JavaScript. So just this one little note in case you get stuck or some functions seem to only fail on your PC.

You check this out for more info https://electronjs.org/docs/tutorial/application-debugging#main-process

I can't really remember the exact names of files and commands but hopefully this will give you enough info to get started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment