POS Terminal interface via COM

I am developing and interface between a java application and a POS terminal for credit card payment.
I have implemented a very simple class to Read data on COM port to which the POS is linked.
This is the code
package com.bnt.iso.util.serial;
import java.io.IOException;
import java.io.InputStream;
import java.util.TooManyListenersException;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.NoSuchPortException;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import gnu.io.UnsupportedCommOperationException;
import com.bnt.iso.util.serial.*;
public class ReadSerialPort implements SerialPortEventListener,Runnable {
     InputStream input;
     Thread readThread;
     SerialPort porta_seriale;
     static CommPortIdentifier id_porta;
     int k=0;
      String result;
      byte[] readBuffer = new byte[128];
      int numBytes;
     public ReadSerialPort(String port)  {
          try{
               id_porta= CommPortIdentifier.getPortIdentifier("COM1");
               CommPort porta=(SerialPort)id_porta.open("ReadSerialPort",200);
                porta_seriale=(SerialPort)porta;
               input=porta.getInputStream();
               porta_seriale.addEventListener(this);
               porta_seriale.notifyOnDataAvailable(true);
               porta_seriale.notifyOnOutputEmpty(true);
               porta_seriale.notifyOnDSR(true);
               porta_seriale.notifyOnBreakInterrupt(true);
               porta_seriale.notifyOnCarrierDetect(true);
               porta_seriale.notifyOnCTS(true);
               porta_seriale.notifyOnFramingError(true);
               porta_seriale.notifyOnOverrunError(true);
               porta_seriale.notifyOnParityError(true);
               porta_seriale.notifyOnRingIndicator(true);
               porta_seriale.setSerialPortParams(9600,
                            SerialPort.DATABITS_8,
                            SerialPort.STOPBITS_1,
                            SerialPort.PARITY_NONE);
                readThread = new Thread(this);
               readThread.start();
               catch(NoSuchPortException ne){
                 System.out.println("Serial Port COM2 NOT Present");
               }catch(PortInUseException pe){
                 System.out.println("Serial Port COM2 owned by "+pe.currentOwner);
               }catch(UnsupportedCommOperationException ue){
                 System.out.println("Serial Port mismatch with params used");
               }catch(IOException ioe){
                 System.out.println("IO Error");
               catch (TooManyListenersException tme){
                    System.out.println("Only one listener");
               catch(Exception e){
                    System.out.println("Only one listener");
     //25757575750575449115495050505649575255310
     //25757575750575449115495050505649575255310
     //257575757505754491154950505056495752550310
     public  void run()
          try{
               Thread.sleep(60000);
               porta_seriale.close();
          catch(InterruptedException e){}
     public  void serialEvent(SerialPortEvent event) {
          System.out.println(" \n Start Event");
          switch (event.getEventType())
               case SerialPortEvent.BI:
                    System.out.print("Case BI");
               case SerialPortEvent.OE:
                    System.out.print("Case OE");
               case SerialPortEvent.FE:     
                    System.out.print("Case FE");
               case SerialPortEvent.PE:
                    System.out.print("Case PE");
               case SerialPortEvent.CD:
                    System.out.print("Case CD");
               case SerialPortEvent.CTS:
                    System.out.print("Case CTS");
               case SerialPortEvent.DSR:
                    System.out.print("Case DSR");
               case SerialPortEvent.RI:
                    System.out.print("Case RI");
               case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                     System.out.print("dati non disponibili");
                    break;
               case SerialPortEvent.DATA_AVAILABLE:
                    System.out.print("Dati disponibili \n");
                    byte[] readBuffer = new byte[16];
                    try {
                         while (input. available()>0) {                              
                               numBytes = input.read(readBuffer);                              
                          System.out.print(new String (readBuffer));
                          System.out.print("\n");
                          System.out.print(CCard_Int_Util.stringToHex(new String (readBuffer)));
                     catch (IOException e) {
                          System.out.print("IO exception " +e.getStackTrace());
                          break;
     public  static void main (String[] args){
          char STX = (char)0x02;
           char ETX = (char)0x03;
           char ACK = (char)06;
           char LRC_7A = (char)0x7A;
           char LRC_3D = (char)0x3D;
           char NP_13 =  (char)13;
           char NP_12 =  (char)12;
           char NP_46 =  (char)46;
           char NP_26 =  (char)26; //1A
           char NP_61  = (char)61;
           String codComm = "000000";
           String idTerminal = "00";
           String filler = "000";
           String ackPos = "0"; //2
           String CardType = "0";
           String infoCard = "0";
           String closePOS = STX+"000000000C"+ETX+NP_13;
           String openPOS = STX+"000000000B"+ETX+NP_12;
//           String payPOS = STX + codComm + idTerminal + "P" + "000000000"+ETX+NP_46;
           String tot =       STX + "000000000" + "I" + "00000,100000000000"+ETX+""+NP_26;
           String payPOS =STX + "000000000I00000,10"+"0" + ETX + "" + NP_46;
           String Import_payPOS =STX + "000000000P000000000" + ETX + "" + NP_46;
           String ACK_Mex = ACK + "" + ETX + "" +LRC_7A;
           String Status = STX+"000000000s"+ETX+""+NP_61;
           //ControlSerialPortNT.WriteSerialPortNT(openPOS);
           ControlSerialPortNT.WriteSerialPortNT(payPOS);
          ReadSerialPort read= new ReadSerialPort("COM1");
               try {
                    read.finalize();
               } catch (Throwable e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
}The problem is that
Performing EXACTLY the same actions sometimes the response of the POS is the following
FIRST CASE :
Read Event 1
2393939393239363031493b000
SECOND CASE :
Read Event 1
23939393932393600000000
Read Evcet 2
3031493b00000000000
Do you think that this could be a problem of synchronyzation or something like that or it is possibly a problem of the hardware ?
Thanks a lot.

The program is intended for personal use, so yes, practice. In total, I want my program to provide a new interface for command.com. I want to learn how to use the in/out streams of command.com to achieve this. Currently I am substituting cmd.exe for command.com because java won't display the input stream properly (alternate encoding perhaps? I don't know enough about encodings or command.com though). But I'm not worrying about that so much as how to pass a command to the process. I've tried writing the string of a command with and without the \n character to the output stream, but it doesn't cause the input stream to change at all. The only way I have successfully executed a command is by using batch mode, so that is the big problem with this right now.
Edit: I am aware that you can execute commands one-at-a-time by using parameters, it just seems silly to have to re-run the process every time i need something.
Edited by: R_Neufeld on Aug 4, 2008 9:36 PM

Similar Messages

  • Can not access ASAs inside interface via VPN tunnels

    Hi there,
    I have a funny problem.
    I build up a hub and spoke VPN, with RAS Client VPN access for the central location.
    All tunnels and the RAS VPN access are working fine.
    I use the tunnels for Voip, terminal server access and a few other services.
    The only problem I have is, that I could not access the inside IP address of any of my ASAs, neither via tunnels nor via RAS VPN access. No telnet access and no ping reach the inside interfaces.
    No problem when I connect to the interface via a host inside the network.
    All telnet statments in the config are ending with the INSIDE command.
    On most of the ASAs the 8.2 IOS is running on one or two ASAs the 8.0(4).
    For the RAS client access I use the Cisco 5.1 VPN client.
    Did anybody have any suggestions?
    Regards
    Marcel

    Marcel,
    Simply add on the asas you want to administer through the tunnels
    management-access
    http://www.cisco.com/en/US/docs/security/asa/asa82/command/reference/m.html#wp2027985
    for asa5505
    management-access inside
    for all others if you have management interface management0/0 defined then:
    management-access management
    then you may need to allow the source , for example if RA VPN pool network is 10.20.20.0/24 then you tell asa that network cann administer asa and point access to inside, but sounds you have this part already.
    telnet 10.20.20.0 255.255.255.0 inside
    http 10.20.20.0 255.255.255.0 inside
    same principle for l2l vpns
    Regards

  • Select printer when driving PS via COM

    Hi there,
    I am writing an application that drives PS CS2 externally via COM
    (under Windows XP of course).
    I can successfully control PS (run actions, load, perform
    transforms, save, print and so on...)
    all without user interaction. I must say that the interface
    is quite powerful. However, I want some control
    over which printer a file is sent to.
    Specifically, I want to load a file and print it to one
    of 3 available printers (depending on an attribute known to
    my application) without prompting the user.
    I can change the System default printer and then
    broadcast a WM_WININICHANGE (via SendMessage), but of
    course once PS has printed the first time (using
    the System default), it simply sticks with the current printer.
    It ignores changes to the system default. That probably makes sense.
    One way around this is to set the system default printer, and then
    restart PS. But thats **awfully** time consuming, especially on
    the scale I am looking at.
    Is there a better way?
    Many thanks for any insights or hints.
    Paul.
    OS: XP SP2
    Version: PS CS2
    RAM: ooodles

    Network Printer Troubleshooting
    Ping printer: If you have the printers IP address open Terminal (Applications/Utilities) and at the prompt type: ping {printerIP}. You will get a reply or failure.
    If you haven't done so already, try resetting the printing system.
    OS X Mavericks: Reset the printing system  also Yosemite

  • Need help on Point of Sale application communicate to POS Terminal

    Hi Everyone,
    I have developed POS application in forms 6i. i need to communicate to POS Terminal for verify payment.
    If anyone have a solution how to use ocx/dll for POS terminal please help me in this regards.
    my email : [email protected]
    Thanks All.
    Salman

    Hi Everyone,
    I have developed POS application in forms 6i. i need to communicate to POS Terminal for verify payment.
    If anyone have a solution how to use ocx/dll for POS terminal please help me in this regards.
    my email : [email protected]
    Thanks All.
    Salman

  • Talking to Internet Explorer embedded Acrobat Reader via COM

    Hi all. I'm developing an Internet Explorer BHO (browser plugin) and was wondering whether it's possibly for me to communicate with Acrobat Reader via COM. I have read through the SDK docs and it's not clear whether this is possible. I'm using unmanaged c++.
    I think if this can be done I think I will need to call get_document(IDispatch *p) on the webbrowser control, then using p->QueryInterface(...) to gain access to the Acrobat document. However, to do this I will need to pass in a REFIID to QueryInterface. As such I need to find some documentation on the supported COM interfaces and various IDs I will need to use.
    If anyone could point me in the right direction, that would be great.
    thanks,
    Zoltan!

    Thanks for your reply. We are writing a web annotation tool as an Internet Explorer plugin. The web annotation part of it is complete, and now we are looking at being able to make annotations on pdf documents loaded within the browser.
    Where can I find information about the limited APIs on the ActiveX control you mentioned? Do you think we should be looking at a different approach?
    thanks,
    Zoltan

  • Connecting Via COM with Indesign CC Server

    Hi
    We are currently using Adobe CS5 Server - and connecting to it VIA COM.
    We are looking to upgrade to Indesign CC Server - but we want to know if we can still connect to it via COM ?
    Best Regards
    Martin

    Yes, Adobe InDesign CC Server still supports the COM interface, and it is hard to imagine they would change this. If you download and install the trial, you can test it for yourself... looking at page 24 of the "Intro to InDesign CC Server" document that comes with the install, they have all the same language and no indication of any changes related to the COM interface.
    Max Dunn
    Silicon Publishing

  • How to reset Dot11Radio interface via SNMP

    Hi guys,
    Please tell me how i RESET my AP's radio interface via SNMP? It's mean down and up right behind sb.
    I'm using several SNMP commands for manage to our Cisco's. But I'm unsuccessful at this.. Please help me. Thakns.

    Isn't there any response? isn't there any Cisco Specialist at there???

  • Shutdown wireless interface via SNMP Write?

    Hi
    We're working on writing a very simple web app to control a couple of access points via SNMP.  I'm trying to shutdown the Wireless interface via SNMP WRITE with the following oid;
    .1.3.6.1.2.1.2.2.1.7.1
    and
    .1.3.6.1.2.1.2.2.1.7.2
    But its saying the integer of '0' is invalid (badValue, wrong type or length).  I'm able to set other values like hostname, etc, so I know my string is correct...can anyone help?  THanks
    Jason

    Hi
    Just found my own answer...the value to shutdown the interface is not 0, it's 2.  durrr
    Thanks
    J

  • Deal with missing / renamed files via COM interface

    Hello,
    I'm trying to find some way to programmatically identify missing files in iTunes, including where iTunes is looking for the file, and if possible to point iTunes to the correct path. It's very straightforward to detect missing files, the original path could probably be obtained by analysing the iTunes xml file, but I can find no programmatic way of telling iTunes where to look. Simply deleting the missing file and then adding a new file from the new location is not acceptable.
    The reason for wanting to do this is very simple. I've a custom written backend music library management system that presents the library to iTunes as a set of .m4a files on a read only network share. From time to time, new files will appear, existing files will be updated or renamed, and files may be deleted. What I'd like to do is to write some simple vbscript that will keep iTunes in sync with this set of files.
    Most of the functionality it easy. The difficulty comes with dealing with renamed files. I can identify missing files by looking for those with a null location. If I can then find out what the file was previously called, I can then quite readily determine what it will have been renamed to. At this point however, I can find no way to update iTunes. As previously mentioned, just removing and re-adding the file isn't acceptable, as it will then disappear from any devices synced with iTunes.
    Does anyone have any clever ideas how to achieve this. The best idea I've come up with is to brute force the .itl file, and deal directly with that. I'd really rather not though, and it'll be a lot of effort, and may well spontaneously stop working. I'd also like to achieve the same effect of a mac platform, probably with Applescript, but am having basically the same issues.
    Regards,
    Chris
    The reas

    Christopher,
    I, too, wish this could be done. Unfortunately it looks like Apple does not currently have this capability (i.e. the Location property is read-only). I've submitted an enhancement request for this feature (as I'm sure many others have), but this appears to be by design. It appears you have already figured out the only workaround I'm aware of -- adding the file again (and optionally copying the properties from the old file to the new one).
    But by all means, please submit a bug report at http://bugreport.apple.com. Maybe if enough people gripe it will get implemented. You'll need an ADC account to submit a report via that link. If you don't have an ADC account already, you can get a free "ADC Online" account (or, of course, buy a higher-level account if you want).
    If you don't want to get an ADC account, you can use the Apple feedback page (http://www.apple.com/feedback) -- but I think you'll get a better response as a developer via the bugreport site.
    BTW, if you find good documentation on the iTunes Library file, I'd like to see it! I can't find any anywhere. Of course, if you figure it out and you don't want to share that's up to you...

  • Itunes - Changing track location via COM interface

    Hi,
    I transfered from xp to vista with subsequent re-organization of all itunes libraries where I noticed that the old library had already a lot of broken links.
    I wrote a VBA program to intelligently find the new location for broken links, however, I cannot get that information back into itunes as the Location property of IITFileOrCDTrack is read-only.
    Has anyone found out how to do that conveniently without adding each file, and deleting the old library information (which involves also updating playlists etc) - a lot of hassle which is not really required?
    Anyway, does anybody know why Location is read-only?
    Thank you in advance
    --- Peter
    Message was edited by: r007007

    AH! Eureka! Yes this works.
    Thank you very much.
    It is curious though that Apple's own code example doesn't work. Guess I need to start trolling the man pages for more such nuggets.
    Thanks again.
    Bob Jakuc
    Associated Press
    Systems Engineer

  • SJSAS 9.1 does not expose EJB 3.0 remote Interface via JNDI

    I have successfully deployed a simple Stateful EJB 3.0 bean (CartBean, like the one in the Java EE 5 tutorial remote interface Cart) on SJSAS 9.1, located on machine host1.
    After I deployed the CartBean, I browsed the SJSAS and noticed the existence of the following JNDI entries:
    ejb/Cart
    ejb/Cart__3_x_Internal_RemoteBusinessHome__
    ejb/Cart#main.Cart
    ejb/mgmt
    ejb/myOtherEJB_2_x_bean ( +myOtherEJB_2_x_bean+ is a different 2.x bean that I have deployed as well)So, I am trying to access the remote interface of the CartBean from a remote machine, host2. The client application is a Java-standalone client.
    I am using the Interoperable Naming Service syntax: corbaname:iiop:host1:3700#<JNDI name>
    The problem is that the remote interface of the bean does NOT seem to be available via JNDI. I get the javax.naming.NameNotFoundException when I try to do a lookup like:
    corbaname:iiop:host1:3700#ejb/Cart
    On the other hand, the following lookups succeed:
    corbaname:iiop:host1:3700#ejb/mgmt
    corbaname:iiop:host1:3700#myOtherEJB_2_x_bean
    and also the following succeeds:
    corbaname:iiop:host1:3700#ejb/Cart__3_x_Internal_RemoteBusinessHome__So it seems like the Remote interface is not available via JNDI, rather only some internal SJSAS implementation (the object returned from the ejb/Cart__3_x_Internal_RemoteBusinessHome__ lookup is of type: com.sun.corba.se.impl.corba.CORBAObjectImpl
    Why is this happening? I know there used to be a bug in Glassfish, but I thought it had been fixed since 2006.
    Many thanks in advance, any help would be greatly appreciated.

    The EJB 3.0 Remote Business references are not directly stored in CosNaming. EJB 3.0 Remote references do not have the cross-vendor interoperability requirements that the EJB 2.x Remote view had.
    You can still access Remote EJB references from a different JVM as long as the client has access to SJSAS naming provider. Please see our EJB FAQ for more details :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

  • Can't access management interface via vpn connection

    Hi all,
    I can't seem to be able to manage my ASA 5510 when I connect via vpn. My asa sits at a remote colo, and from my office i can connect fine. I have it configured as management-access (dmz), bc as of now we are just doing some staging and all the servers are in the dmz interface.
    When i connect with the vpn client, in the routes it sees 192.168.1.0 255.255.255.0 which is the management network/interface.
    For some reason I can't get access to 192.168.1.1 to use the ASDM.
    Here is how i did my vpn via CLI
    isakmp enable outside
    isakmp identity address
    isakmp policy 10
    authentication pre-share
    encryption des
    hash md5
    group 2
    lifetime 86400
    ip local pool vpnpool 10.1.1.2-10.1.1.10
    access-list split_tunnel standard permit 192.168.200.0 255.255.255.0
    access-list split_tunnel standard permit 192.168.100.0 255.255.255.0
    access-list split_tunnel standard permit 192.168.1.0 255.255.255.0
    group-policy xxxxx internal
    group-policy xxxxx attributes
    dns value
    split-tunnel-policy tunnelspecified
    split-tunnel-network-list value split_tunnel
    username xxxxx password
    username xxxxxx attributes
    vpn-group-policy xxxx
    username xxxxxx password
    username xxxxxx attributes
    vpn-group-policy xxxx
    username xxxx password
    username xxxx attributes
    vpn-group-policy xxxx
    tunnel-group xxxx type ipsec-ra
    tunnel-group xxxx general-attributes
    address-pool vpnpool
    tunnel-group xxxx ipsec-attributes
    pre-shared-key
    access-list vpnra permit ip 192.168.200.0 255.255.255.0 10.1.1.0 255.255.255.0
    access-list vpnra permit ip 192.168.100.0 255.255.255.0 10.1.1.0 255.255.255.0
    access-list vpnra permit ip 192.168.1.0 255.255.255.0 10.1.1.0 255.255.255.0
    nat (inside) 0 access-list vpnra
    nat (dmz) 0 access-list vpnra
    nat (management) 0 access-list vprna
    crypto ipsec transform-set md5des esp-des esp-md5-hmac
    crypto dynamic-map dynomap 10 set transform-set md5des
    crypto map vpnpeer 20 ipsec-isakmp dynamic dynomap
    crypto map vpnpeer interface outside
    Any help would be much appreciated

    it seems like you are missing a line:
    management-access "interface"
    http://www.cisco.com/en/US/docs/security/asa/asa71/command/reference/m_711.html#wp1631964

  • Calling XI interfaces via Java

    Hi All,
    What is the method to call a Interface in XI via Java?
    Regards,
    Keerti

    are you talking about Java Proxy ?
    You can connect to an external Java based system via a Java proxy (XI adapter) - http://help.sap.com/saphelp_nw04/helpdata/en/e1/091640a991c742e10000000a1550b0/content.htm
    Also have a look at these weblogs;
    /people/prasad.ulagappan2/blog/2005/06/27/asynchronous-inbound-java-proxy
    /people/rashmi.ramalingam2/blog/2005/06/25/an-illustration-of-java-server-proxy

  • Export Interfaces via Webservice in ECC 6.0 for SAP Learning SolutionLSO600

    hi *,
    i am pretty new to SAP HR and have found this manual
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/329da1a8-0b01-0010-b399-c04517307bcd
    in this manual it is described that in LSO 600 you either have the possibility to export a SOAP interface directly from the SAP HR Netweaver instance and OR can go through SAP XI for doing this.
    my problem about this is that i can not find a manual for doing this. my preferred way would be to export this soap requests via NON XI (just ECC 6.0).
    does anyone know a manual for exporting this interfaces or similar ones to soap/wsdl?
    regards chris

    And what is the solution?

  • ZBF: Assign zone to interface via Cisco AV Pair

    Hello,
    I am terminating ADSL connections via an L2TP tunnel from a service provider and have configured Cisco AV Pairs to assign incoming sessions into different VRFs based on the username of the remote router. I am also using Zone Based Firewall configuration and need to also assign the created virtual access interface into a zone in the same manner as I am assigning VRFs.
    I am assigning VRFs like so:
    Cisco-AVpair+=ip:vrf-id=<vrf-name>
    I have tried assigning a zone with the following configuration but with no luck:
    Cisco-AVpair+=ip:interface-config=zone-member security <zone-name>
    Cisco-AVpair+=lcp:interface-config=zone-member security <zone-name>
    I have looked around but am unable to find a definitive list of Cisco AV Pairs to determine if there is one suitable specifically to assign a zone or a more generic AV Pair that can assign arbitrary configuration.
    Any help appreciated.
    Thanks.

    For anyone else who has a similar issue, I raised the issue with Cisco TAC and the solution was to use a Cisco AVpair of
    lcp:interface-config=zone security <zonename>
    I also had to add:
    aaa policy interface-config allow-subinterface
    Once I did this it worked a treat.

Maybe you are looking for

  • Macbook Aluminum to VGA Output

    I have a Macbook Aluminum and I am trying to output that to my TV. I have bought the miniPort to VGA adapter and hooked it up to my LCD TV with a VGA input. When this happens, I am only able to see my desktop background and nothing else. It will not

  • Late 2007 MacBook questions

    I've heard that this model has issues with the video going out. I recently aquired one in great shape and was curious if I should use it or sell it. Also how would I go about tightning up the hinge on the notebook?

  • Getting Color to only render between in an out points

    When I import into FCP, I generally create slices of my movies between 1 and 5 minutes depending on what is in them. Then I slice them up with multiple in and out points and place them on my time line. This is all good until Color gets in the mix and

  • ORA-10827: database must be opened with MIGRATE option

    Hi, We are trying to migrate an Oracle 8.1.7 database to an Oracle 9i(9.2) database. I moved all the database files to the appr folder and I created a new instance using: oradim -new -sid PROD -intpwd Oracle -startmode a -pfile C:\oracle\OraDb\Neurop

  • Why do templates use .classes so much instead of DIVS?

    I really thought DIV's were the way we named once-off major columns and sections across our site, yet when I look into the DW templates they are all classes with unusual names. Yet I thought CSS were moving to standard naming conventions like.... div