Barcode scanner, keyboard wedge

I've got this barcode scanner with PS/2 connector that refuses to work on my PC. It appears to freeze when I try to scan anything other than Configuration codes.
I have come across some information that some scanners will not work without a keyboard connected to the other side of the keyboard wedge cable. I have no idea if this scanner requires it, since I don't have a PS/2 keyboard at hand to test it. I haven't been able to find anything relevant in the documentation, except perhaps the entry "Enable stand-alone keyboard (Required no keyboard or key simulator. Only available for special firmware version.)". However I have no idea how to get the special firmware.

So, does anybody have any experience with this sort of things? Is there a simple way to trick the scanner into thinking there is a keyboard attached? How does it even know there is no keyboard?

I've a couple of used but working PS2 keyboards, with a UK layout, that you can have for free. It will make some space in my attic. :slight_smile:
The problem is getting them from London to Croatia. :frowning:

Just an outside guess, but if you have a PS/2 mouse, try plugging that in as an experiment!

Henry, that is a really nice offer but as much as I'd like to help you clean out your attic, the proposition is somewhat impractical.

Paul, thanks for suggestion. Unfortunately when I moved a few years back I either left all my old computer hardware at the old home or just threw them away, so no PS/2 mice either. However I asked around for PS/2 devices and, of all people, my mom triumphantly produced a USB to PS/2 adapter. Without much enthusiasm I hooked up a USB mouse via the adapter to the wedge cable and what do you know, the scanner works!
4010995268183
See? That's a barcode scanned!

Now, what I need to do is to figure out how to get the thing working with the Arduino and how to fool it into thinking there is a keyboard (or mouse) attached. Well, there is enough room in the project enclosure to fit entire keyboard so if I take out the guts of a PS/2 mouse and just leave the board.... Now I'm thinking out loud.

Anyway, thanks guys!
I think I'll clean up the original post, now. There is some horrible stuff up there.

Shpaget:
of all people, my mom triumphantly produced a USB to PS/2 adapter.

That's pretty novel. I have a number of the opposite adaptors, which are particularly useful for computers in display-only situations (such as my office door sign) or network-only situations which insist on a (USB) keyboard to start. It turns out that the adaptor itself suffices, even without the keyboard.

I also forage garage sales and "roadkill"; a free USB keyboard with missing keys provides the PCB itself (very compact nowadays), though one usually wants to shorten the cord.
Or you might want to use only a few keys in some project.

Those adapters are miracle workers, I suppose. I pulled the plug (literally) on the USB mouse I had plugged in the adapter and the scanner continued to work even after several power cyclings of both scanner and the PC.
So I went a step further and managed to hook the thing to the Uno. Works like a charm with two different codes I found online. It scans the codes and spits them out the serial port as a stream of chars.

That’s where I hit the next problem. This is now turning into programming question and is no longer “General Electronics” related, but somehow I believe opening a new topic would not be a good idea as somebody else might find this useful in the future and would like all the available info in one place. However, if Mods decide otherwise I’ll move the rest of the discussion upstairs.
Given my rudimentary coding skills, I am having some trouble converting those chars to numbers, which I believe I can work with more easily.
The current code is:

#include <PS2Keyboard.h>

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

unsigned long scannedCode;
bool flag = false;
unsigned long prevMillis;
int scanDelay = 500;

void setup() {
  delay(1000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
  Serial.println("Keyboard Test:");
}

void loop() {
  if (keyboard.available())
  {
    flag = true;
    while (keyboard.available()) {
      // read the next key
      char c = keyboard.read();
      scannedCode = scannedCode * 10;
      scannedCode = scannedCode + (c - '0');
      prevMillis = millis();
    }
  }
  if (flag == true)
  {
    if (millis() - prevMillis >= scanDelay)
    {
      Serial.print(" scannedCode = ");
      Serial.println(scannedCode);
      scannedCode = 0;
      flag = false;
    }
  }
}

Link to the library I’m using.

You’ll probably notice the clumsy method of converting char to long, but it’s the best I could do myself. Suggestions on how to improve this part are welcome.
The main problem is that when I scan a code 123456 it displays it as 1234525. Scanning 11235813 results in 112358095 being printed in serial monitor.
I can easily rectify this by changing
Serial.println(scannedCode);
to
Serial.println((scannedCode+35)/10);
but that solves the symptom not the cause. My understanding of ASCII is obviously not good enough since staring at the ASCII table did not produce a light bulb over my head.
What is the significance of 35?
All I can think of is 3+5 = 7 → 35 + 7 = 42.

I had a moment of clarity and realized the problem, so in case somebody is following this or stumbles upon this thread in the far future, long after the decline of human race, here's the solution to the problem I had.

The scanner ended the transmission of the scanned code by simulating the pressing of the Enter key. Obviously trying to convert Enter to a number will fail miserably. with weird consequences.
Fortunately the scanner came with the configuration codes and turning off the message terminator was trivial.
Happy times!