I am working on a project that involves a bar code scanner connected via serial (PS2). I have it and the other components hooked up properly to the spark core, but am running into problems porting the library. I have seen the other threads - the most relevant, although somewhat stale, is this one. Has anyone had any success in this department yet? If so, I would love an opportunity to pick your brain on the modifications you have made/plan on making. Please let me know - I am very willing to put in time and effort here and collaboration might be a mutually beneficial strategy.
can you post a link of the library to be ported so that we can have a look?
Apologies for excluding the library, that was my oversight - please find it here.
I have taken a look through the libraries that have already been ported/created and uploaded and haven’t found another version of this. Thanks so much for the quick reply, looking forward to working on this.
Just curious why PS2? You require a physical keyboard?
The core can somehow send keystrokes and mouse control though it’s not extensively tested!
Let me know while i explore the library
When I began the project, I was using an Arduino. The bar code scanner that I am using supposedly worked well with Arduino when accompanied by the library I linked in the last post.
Do you have a different/better option for communicating with a bar code scanner? Thanks again for all the help already - this is an incredible community.
I don’t have suggestions for that but it was more of a curiosity question! If i managed to port this, i can use a barcode scanner in future as well.
Do you have a link of the the barcode scanner you bought?
I see that porting might be slightly challenging with the Arduino specific PROGMEM code but they seem to have it working on teensy. Will update you
The words “bar code scanner” in my last post are linked to the one that I purchased.
You’re definitely correct on PROGMEM being an issue. Looking forward to collaborating - please let me help out in anyway possible.
Ok so i hacked them together already
Did you install spark-cli? That’s the fastest way to send you the files and test to see how it goes!!
If it works, i will ask the other Elites on how to add in the conditional statement for spark and it should be published as a modified library
Ha! That was impressively fast. I had been using the web IDE and do not have spark-cli installed yet but it seems straight forward. What information do you need to send it? I’ll get it installed this evening.
Thanks so much again.
It’s just more convenient to compile via the command line instead of copy and pasting into the web ide during development.
makes it much faster!
Just installed spark-cli. The accepting xCode terms/conditions was holding me up for a moment (using a Mac), but once I accepted the agreement all went smoothly. I am ready to go but have a limited comprehension of what is possible with spark-cli vs. the web IDE - I’ll read up on this. In the near term, what are the next steps using spark-cli?
The spark-cli github repo has some usage instructions you can take a look!
Here’s the link: https://dl.dropboxusercontent.com/u/36134145/PS2Keyboard.zip
once you have spark-cli working,
Login to spark-cli using
cdto the directory that you unzipped the file
Use this command
spark flash CORE_NAME PS2Keyboard. be sure to change your own core name
I used one example code to test if i could compile successfully so do modify it before compiling and test on your core.
Hope it works!!
I really can’t thank you enough for all the help so far. So I have read up on spark-cli and have attempted to flash the library/modified example code to the core but I am running into an issue that is causing the spark core LED to breath green. The result in terminal is I want to make sure I understand the components in the zip file as I think I am likely making a mistake here. The files that need to be compiled to assemble the library are PS2Keyboard.h, int_pins.h, and PS2Keyboard.cpp. The final component should be a simple example sketch that allows the serial monitor to display bar codes that have been translated through the library, in this case, test.ino. Am I missing anything so far? I tried isolating these files in a directory and flashing them to the core using spark-cli, but this failed. Does another file in the unzipped folder must serve a purpose that I don’t understand yet?
I also tried copying the contents of the .h, .cpp, and example sketch to the web IDE and was unable to compile them, receiving the following error:
In file included from ../inc/spark_wiring.h:29:0, from ../inc/application.h:29, from bc_reader.cpp:30: ../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp] #warning "Defaulting to Release Build" ^ bc_reader.cpp:44:22: fatal error: int_pins.h: No such file or directory #include "Arduino.h" // for attachInterrupt, FALLING ^ compilation terminated. make: *** [bc_reader.o] Error 1 Error: Could not compile. Please review your code.
Do you see what I might be missing in order to achieve a successful compilation?
Are you in one directory above the
Eg. I have the PS2keyboard folder in desktop. So in my terminal it shows
KEN-MBP:desktop kennethlimcp$ spark compile PS2keyboard Including: PS2keyboard/PS2Keyboard.cpp PS2keyboard/PS2Keyboard.h PS2keyboard/int_pins.h PS2keyboard/test.ino attempting to compile firmware pushing file: PS2keyboard/PS2Keyboard.cpp pushing file: PS2keyboard/PS2Keyboard.h pushing file: PS2keyboard/int_pins.h pushing file: PS2keyboard/test.ino Memory use: text data bss dec hex filename 78096 1228 11932 91256 16478 /spark/compile_server/shared/workspace/3_compile-server2/core-firmware/build/b13a23d22fa1c1d9967001d7c43fbb05918821c1100a164c934308c60d0c.elf grabbing binary from: https://api.spark.io/v1/binaries/546aa19c0030fc0a2a309ab4 saved firmware to /Users/kennethlimcp/Desktop/firmware_1416274329875.bin Compiled firmware downloaded. KEN-MBP:desktop kennethlimcp$
You need to modify the 2 Pins in the
test.ino to suit your setup and test
Ha! Success - I was in the correct directory and had changed the pins, but was still not able to compile. I reset the core, exited the web IDE and the Spark Dev desktop app and was able to compile/flash successfully. Thanks for all the help troubleshooting. As you mentioned, I now need to design a way to test and store the bar codes. I’ve read about a method the bring data to a google spreadsheet which I think will suit my needs nicely for now. In terms of actually ascertaining the data, do you know a good resource I could use learn the best ways to accomplish this? I have been looking for information on the spark core’s IRQ pins and whether or not the data would be available in the serial monitor. Any tips on what to search for to learn about this?
@btheye, the Spark documentation is a good place to find the info on interrupt pins:
Does the code work? I will publish it and have it on the Web IDE library so others can use it
It compiles fine but are you able to output to the serial?
I haven’t been able to output yet, but I am not sure that the problem is with the code. Should it work with no action at all from my end? In other words, should I be able to push the button on the bar code reader and see the output in the serial monitor? When I attempt to view the serial monitor I receive the following:
ben-theyes-mbp:library bentheye$ spark serial list Found 1 core(s) connected via serial: 1: /dev/cu.usbmodem621 ben-theyes-mbp:library bentheye$ spark serial monitor Opening serial monitor for com port: "/dev/cu.usbmodem621"
Whoops, that’s the second result on Google, I don’t know how I missed it. Apologies for that, must need another cup of coffee.