Closed kshanawaz closed 2 years ago
I'm unfamiliar with Mirth Connect. If you try using jSerialComm directly through a Java application, are you able to enumerate the ports you expect to see? I suspect there is something wrong with the way the library is getting wrapped inside a Javascript program.
Closing as not a jSerialComm bug but rather a use-case bug which can't be fixed within this library. For bugs related getCommPorts returning an empty list, please refer to #305.
Hello,
I am starting with my first project to receive data from a serial port. I have used com0com to set up a virtual COM port CNCA0. I am able to send the date to this port using Serial Port Monitor application. I am now writing a code to read data from this port and every time the code runs, it says port has shutdown or is disconnected.
I am writing this code in Mirth Connect using Javascript and here is the code.
importPackage(Packages.com.fazecast.jSerialComm.*);
var comPort=new Packages.com.fazecast.jSerialComm.SerialPort.getCommPort("CNCA0"); var comPorts=new Packages.com.fazecast.jSerialComm.SerialPort.getCommPorts(); logger.info('Comports->'+JSON.stringify(comPorts)); comPort.openPort(); //comPort.setComPortTimeouts(new Packages.com.fazecast.jSerialComm.SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 0, 0); var indata = new java.lang.StringBuffer();
reader = comPort.getInputStream(); //inFromClient //logger.info('numRead->'+JSON.stringify(reader)+' '+typeof reader+':'+reader) try { for (j = 0; j < 1000;j++) { r=reader.read(); c=new java.lang.Character(r); logger.info('char->'+c); } reader.close(); } catch (e) { logger.info('error->'+e) } comPort.closePort();
: When I tried using get commPorts(), it returned this Comports->[null,null,null,null].
What am I missing here?