Installing the Scanner Scale
An IS4C lane connects to the scanner scale via the serial port. Before the computer and the scanner-scale can communicate, the usual serial communication parameters, namely, baud rate, parity, handshake, stop bit, data bit, have to be identical on both the computer and the scanner-scale. We'll worry about the computer first.
Testing the connection
If your serial port is /dev/ttyS0 and you are using a Magellan scale, you can probably skip most of what follows and go directly to the summary below. If, however, you want to immerse yourself in the nitty gritty, do continue.
IS4C assumes that the first serial port is at /dev/ttyS0. Ascertain that it is the case on your system. The traditional method for testing and troubleshooting the serial port is to use a null modem cable to connect the computer to another with known serial port settings and then try to communicate back and forth. We won't resort to that. Not yet.
plug the scanner-scale into the serial port, and check that it is ready to scan. issue the command
cat /dev/ttyS0Scan a barcode. If /dev/ttyS0 is your serial port, you should be able to see some input - doesn't matter that the input might look a bit strange for now. If nothing happens, then you have to identify where your serial port is, or what's wrong with it. The older standard is /dev/cua0, but that is now uncommon - deprecated, as they say. We assume that it is /dev/ttyS0.
Give write permission for Apache-PHP to use /dev/ttyS0. I open it up completely:
chmod 777 /dev/ttyS0Set some of the communication parameters by running the script
/pos/is4c/mysql/setportThe command in the script is
stty 9600 oddp crtscts -F /dev/ttyS0corresponding to:
Baud rate = 9600
By a happy coincidence, these happen to be the "out of the box" factory defaults for the Magellan 8500.
Run the command
again and scan something. If you see a short prefix followed by the barcode translated into the right numbers on the screen, then the serial settings are correct.
You shouldn't have to program Magellan scales, since IS4C is configured to work with them. However, if you are not using a Magellan scale, and the input on the screen are not barcode numbers, don't panic, we just have to program the scanner scale to the same settings. Usually this is done by scanning a series of special barcodes provided by the manufacturer. Follow the manufacturer's instructions. Should it become necessary for you to program the scanner scale, these are the IS4C settings that correspond to common scanner scale factory defaults.
Now let's try sending data from the computer to the scanner-scale.
echo -e "S334\r" > /dev/ttyS0If you hear a beep, all is well.
To summarize this section on testing
Test for scanned input with
cat /dev/ttyS0You should be able to see a string of number corresponding to the barcode.
Test for output to to the scanner-scale with
echo -e "S334\r" > /dev/ttyS0You should hear a beep.
If the results are unsatisfactory, the system won't work properly and you will have to program the scanner scale with special barcodes provided by the manufacturer.
The Scanner-Scale Daemon ssd
IS4C works with the scanner scale by continuously polling the serial port with a c program. The source is at /pos/is4c/rs232/ssd.c The program is compiled into a daemon 'ssd' and set to run at boot time, so that the lane computer is always listening to /dev/ttyS0. ssd performs two functions.
1. It separates data coming in from the scanner-scale as either scanned data or scale data based on the prefix of the data stream. Scanned data is written to the file /pos/is4c/rs232/ssddata/scanner and scale data is written to /pos/is4c/rs232/ssddata/scale. Data streams that are mis-formed and garbled, and otherwise cannot be ascertained to be either, are discarded.
2. While scanned data comes in directly as an ASCII streams, scale data has to be polled. ssd sends commands to the scale based on previous responses from the scale in a continuous polling process to capture weight readings.
To get ssd up and running,
Apache-PHP needs read permission for /pos/is4c/rs232/ssddata/scale; read and write permission for /pos/is4c/rs232/ssddata/scanner. It also needs execute permission for the script files in /pos/is4c/rs232/. ssd needs write permission for /pos/is4c/rs232/ssddata/scale.
Issue the command
mount -t tmpfs -o size=2m tmpfs /pos/is4c/rs232/ssddataThe default 2m is probably overkill. Pick a size you like, remembering that however much memory you specify will be lost to other processes. Arrange for mounting at boot time by putting the command in /etc/init.d/rc.local. There is probably a way to do it in /etc/fstab, for those who know these things.
For permission, I open everything up to keep the headaches at bay
chmod -R 777 /pos/is4c/rs232
Let's check to see if everything is in place.
tail /pos/is4c/rs232/ssddata/scaleIt should say 'S143'. Put a weight on the scale and read the file again. The weight should now be reported following the prefix 'S144'.
Here's some more information.
Magellan provides the following document detailing the polling behaviors of their single cable RS232 scales.
One Final Detail
When the scanner scale comes from the factory, it is set to give a "good read beep" whenever a barcode is successfully scanned. A good read beep, however, does not guarantee that the data stream is properly sent to the serial port and captured by IS4C. An item is only truly rung in when it is written into a table in the translog database. IS4C therefore asks the scanner scale to make a beep whenever an item is correctly inserted. When an item is successfuly rung in, with a scanner-scale that has just been taken "out of the box", the system will therefore make two beeps - the machine good read beep, and the IS4C insertion confirmation beep. The gap between the two beeps gives you an indication of how fast, or slow IS4C is running. Two beeps per items, however, assault the senses.
At the Wedge, we disable the machine good read beep, so that the cashier only hears one beep - the IS4C confirmation beep. If there is no beep, the item has not been inserted into the database, and it has to be scanned again. The machine good read beep has to be diabled by directly programming the scanner-scale with the special series of programming barcodes. Consult the documentation from the manufacturer.