1

I'm trying to get a check-scanner to transmit image files to my Mac (the company only provides Windows drivers). I have the technical manual that specifies all the commands that can be sent to the device, and I'm trying the most basic commands first (blink the LED, print serial number, etc.).

I have been able to successfully communicate with the device using "Serial Tools", but I'm trying to use bash for more control of the input/output and to eventually write an automated script.

After reading a few other posts and trying several things, so far I've tried this: Opening the port with stty command and various flags, for example:
stty -f /dev/tty.usbserial-A5002TeW speed 9600 cs8 cread clocal
stty -f /dev/tty.usbserial-A5002TeW raw speed 9600 -cstopb -parity -echo

Trying to send commands over echo:
echo $'LE 100\cM\cJ' > /dev/tty.usbserial-A5002TeW
--Note that the serial device is connected through a USB adaptor, but responds (at least in Serial Tools) as a regular serial device after I installed the right drivers for it.
--I'm trying to use the \cM\cJ characters because as the device was intended for use by Windows boxes I figured I should use their control codes, I've tried multiple permutations of the code.

The Problem: No matter what happens, the device never responds (no blinky LED lights, no output, etc) and my bash shell hangs until I stop it (^C). I know I can probably use a Python library, and I might wind up doing that, but I'd like to at least see some basic functionality with the bash shell.

Will Bates
  • 81
  • 1
  • 4
  • Posting as a comment since it mostly likely isn't the problem: try using `echo -n` or `printf` to print your string without the extra newline that `echo` alone will produce. – chepner Mar 29 '13 at 19:10
  • OK, so after some more messing about, I can get some things working, but instead of using the \cM\cJ I send in \r\n. I can get the LED lights going etc. etc. Now I just need to be able to reliably get data back from it, I have been doing `cat /dev/tty.usb-etc` which sort of works, but seems to have a timing problem in that I'll get the full output only every now and then, normally I'll get pieces and parts. – Will Bates Mar 29 '13 at 20:54
  • 1
    Your terminal is probably buffering input/output. Does your USB device have a `cu` variant in `/dev`? Something like `/dev/cu.usb-etc`. This is a more raw type of socket, which is probably what you need. Also take a look at `setserial`. More tips in this related post: http://stackoverflow.com/questions/3918032/bash-serial-i-o-and-arduino Please make sure to report back on the solution that works for you, I'd like to know too :-) – Martijn de Milliano Mar 29 '13 at 21:05
  • That worked!!! All I had to do was `stty -f /dev/cu.usbserial-blah speed 9600` and then all my normal echo commands worked like a charm. Thank you!!! – Will Bates Mar 29 '13 at 21:27

1 Answers1

0

Another option would be to try to get it working under a VM (VirtualBox, Fusion, Parallels, etc.) by installing Windows in the VM on your Mac.

Most cumbersome solution, because you'd have to reboot all the time, dual boot your Mac into windows.

Finally, I have an app on my iPhone from my banking institution that simply uses the camera in the phone to photograph the front and back of a check, and they'll accept it that way. This might be an option.

Randy Howard
  • 2,165
  • 16
  • 26
  • Sadly, that is not an option, this is a very small device that customers would plug in directly to their machine to read checks. We can already support customers using Windows machines, but there is as of yet no option for Mac users. The device only has a serial port, so that's pretty much the only way anyone will be getting the images off it. – Will Bates Mar 29 '13 at 16:01
  • See my edit I was making just as you posted this. Perhaps that will work. – Randy Howard Mar 29 '13 at 16:01
  • I appreciate your help, but I'm fairly certain there is no monkey business going on behind the scenes with the hand-shaking. I've already been able to use some of the basic commands using the "Serial Tools" utility on my Mac, I'm essentially just trying to reproduce my success there in a bash shell. – Will Bates Mar 29 '13 at 16:08
  • Fair enough. I don't see anything obviously wrong with your terminal settings, and not having the device here to play with, I can only wish you luck with it. – Randy Howard Mar 29 '13 at 16:10