Ethernet Communication With Zebra Printer by Using Python.

For a long time, writing this note was in my mind.


Why did I need to develop this code?
Supplier send navigation to our factory and they have contractor to control parts as visual and functional to find defect parts during transportation from Korea to Turkey. But test machine doesn't record test result. Operator can easily feed parts to line without control and no one can understand whether parts has been controlled. Also If new software has been released by supplier all stock should be updated by contractor. So many parts has been sent to customer as non-updated and functional faulty.

Almost one year ago, I contacted with our navigation supplier to get their test machine's software updated. They insisted on impossibilities. It was my turn.

Let me share program interface for better understanding.



Firstly I checked their test machine software to find some file that I need. Eventually I found LAST_HISTORY.log file in software root folder.

File contains some data I need.


File end with data as shown red rectangle in above image. It means operator has controlled part as OK. If end of line finish with STOP, code=4, USER-STOP, means operator stopped program before finishing test. If end of line finish with STOP, code=3, FAIL, there are some NOK step.

Last history contains software, micom, Bluetooth, GPS and some other specification of navigation in middle of file as well. Yeeeepp so I can control last updates through this file.

If all these data matching correct ones, printer will give QR barcode which will be used by logistic members. Without reading barcode they can not feed parts to line.

Let's find EOL of last history.


Now finding versions of navigation.



We have to compare all this info with our current version. I create configFile.log to store current version.


Now we can compare all these data with each other with simple if statement.


Test machine is not logging hisyory file, actually log file is so important to prove part has been controlled correctly. The log file is stored in the file named by the serial number of the navigation. By the way I obtained navigation serial data from barcode of navigation through barcode reader.

If end of las history finish with FAIL, we have to reject printing barcode through this code block.


Section up to here was about the general logic of the program.

Zebra Printer can be run with ZPL and EPL.

Below you can see the printing function through ethertnet.


Of course program control so many things. For example after completing inspection as OK, operator can push check&save button so many times and can attached all this barcode to other navigations. To prevent this kind of non-conformance situation, program provide counter actions.

You can see the all code on my GitHub repository here. 


Comments