hi everyone,
i have 1 question
how to open cash drawer with java?
Printable View
hi everyone,
i have 1 question
how to open cash drawer with java?
Hello lephoe,
Welcome to the forums.
Can you please give us some more information?
I need to know what type of cash drawer this is.. How its connected to the PC etc etc. Please give as much information as possible.
I use a usb printer to open a Cash Drawer. connected to the pc via usb
how to open a Cash Drawer at the time of printing?
Who is the cash drawer made by? Do you have the manual?
Please give me a model number if possible. Also, who is the USB printer made by?
This info will help me find out what information needs to be sent to open the cash drawer. All models are different.
I have been able to open Cash Drawer
My problem now is how do I open ports COM3
please help friends
it is the source code
Code :package testConn; import javax.comm.*; import java.util.*; /** Check each port to see if it is open. **/ public class openPort { public static void main (String [] args) { Enumeration port_list = CommPortIdentifier.getPortIdentifiers (); while (port_list.hasMoreElements ()) { >>> [B]this process in the past, why did not you?[/B] // Get the list of ports CommPortIdentifier port_id = (CommPortIdentifier) port_list.nextElement (); // Find each ports type and name if (port_id.getPortType () == CommPortIdentifier.PORT_SERIAL) { System.out.println ("Serial port: " + port_id.getName ()); } else if (port_id.getPortType () == CommPortIdentifier.PORT_PARALLEL) { System.out.println ("Parallel port: " + port_id.getName ()); } else System.out.println ("Other port: " + port_id.getName ()); // Attempt to open it try { CommPort port = port_id.open ("PortListOpen",20); System.out.println (" Opened successfully"); port.close (); } catch (PortInUseException pe) { System.out.println (" Open failed"); String owner_name = port_id.getCurrentOwner (); if (owner_name == null) System.out.println (" Port Owned by unidentified app"); else // The owner name not returned correctly unless it is // a Java program. System.out.println (" " + owner_name); } } } //main } // PortListOpen
So that code opens the cash drawer?
What do you need to do with COM3? Whats the issue?
I was able to open a Cash Drawer. code was to display the text into line displays
and I have just completed.
thanks
Have you solved this issue?
yes, i have.
I use the cmd command, because the API javax.comm command I did not understand
This command to the API javax.comm :
package testConn;
import javax.comm.*;
import java.util.*;
/** Check each port to see if it is open. **/
public class openPort {
public static void main (String [] args) {
Enumeration port_list = CommPortIdentifier.getPortIdentifiers ();
while (port_list.hasMoreElements ()) { //This part in the diving, why not you?
// Get the list of ports
CommPortIdentifier port_id =
(CommPortIdentifier) port_list.nextElement ();
// Find each ports type and name
if (port_id.getPortType () == CommPortIdentifier.PORT_SERIAL)
{
System.out.println ("Serial port: " + port_id.getName ());
}
else if (port_id.getPortType () == CommPortIdentifier.PORT_PARALLEL)
{
System.out.println ("Parallel port: " + port_id.getName ());
} else
System.out.println ("Other port: " + port_id.getName ());
// Attempt to open it
try {
CommPort port = port_id.open ("PortListOpen",20);
System.out.println (" Opened successfully");
port.close ();
}
catch (PortInUseException pe)
{
System.out.println (" Open failed");
String owner_name = port_id.getCurrentOwner ();
if (owner_name == null)
System.out.println (" Port Owned by unidentified app");
else
// The owner name not returned correctly unless it is
// a Java program.
System.out.println (" " + owner_name);
}
}
} //main
} // PortListOpen