c - ESC/POS printer Java -


i have datecs mp55 cashregister. want develop code in java print. documentation poor , use help.i've read somewhere need send command it's port, don't know command , way sending it, how port uses. found far :

1.1. prnopen opens serial port , performs initalization of printer  syntax int __stdcall prnopen(int port, int speed, bool hardware);  parameters port com port number speed com port speed hardware if true, turns on rts/cts handshaking, false goes xon/off  return value err_ok - printer ready err_timeout - communication error 

so c code. i've created sample code test c doesn't have bool type ... :

#include <stdio.h> #include <stdlib.h>  void hellofromc(){     printf("hello c!"); } int __stdcall prnopen(int port, int speed, bool hardware);  int main(){  hellofromc();  return 0; } 

so without int __stdcall prnopen(int port, int speed, bool hardware); able run code in java. also, way calling c code in java :

import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader;  public class test {     public static void main(string[] args) {         try {             string filename = "d:\\eclipse\\workspace\\testing\\testfile.exe";             runtime rtime = runtime.getruntime();             process p = rtime.exec(filename);             bufferedreader inputreader = new bufferedreader(new  inputstreamreader(p.getinputstream()));             string line = "";             while((line = inputreader.readline()) != null){                 system.out.println(line);             }         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     } } 

and here how creating communication ports :

import java.util.*;  import gnu.io.commportidentifier;  /** list ports available on local machine. **/ public class listports { public static void main (string args[]) {  enumeration port_list = commportidentifier.getportidentifiers(); system.out.println("start"); while (port_list.hasmoreelements()) {        commportidentifier port_id = (commportidentifier)port_list.nextelement();     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());  } system.out.println("end"); } // main } // class portlist 


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -