Strange init serial port issue
Hello:
My Labview application is reading data from the COM1..COM6 ports (I have
added a MOXA serial board to get 4 more ports). I am using RS232 reading
on each port (old legacy Vis, 9m long communication cables). The devices to which I am connected are weigh scale that continuously send weight readings to the Labview app through 3-wires RS232 (RD, TX and GND). Everything goes well for hours and hours. Then after a while (maybe after power is cut and restarted on the PC side?) I restart the PC and launch Labview. If I try to init the serial port that I use to connect to the weigh scale I get an error 37. I also tried to init thru HyperTerminal right after restarting the PC and could not. The only thing that works to unlock the port is
this:
- unplug the weigh scale communication cable from the Moxa connector
- restart the PC
- relaunch LV or HyperTerminal
Unplug then restart Labview or HyperTerminal is not sufficient.
To the same Moxa board I connect other devices such as PLC or PC through serial ports but never see any problems even after restarting the Host PC. So there is something strange with weigh scales (I tried two different brands) but what? I cannot use the built-in serial port as it is already in use by another application.
Does someone out there have an explanation and ways to avoid this very annoying problem?
Thank you very much, I am completely lost,
Christophe
Chris:
Thank you for your help. I investigated the problem further and this is what I found. I am still clueless so if you think of other tracks that I might explore I would be glad to hear them.
- Hard boot (power off, remove power cord, restart) does not release the port
- I change the port ie. I used the built-in COM1 PC port, got the communication, could read char, then restarted the PC and fell into the same trap: could not init the port (Labview). I did the same after restarting and could not open the port with HyperT. Hence it is not a Moxa issue.
- The question is: how can I resolve that, is it an HW or SW issue, a combination of the two, has it got something to deal with WIndows 2K, are there some tools that allow to diagnose whi
ch service or application grasps the serial port during the boot sequence? Or is it a problem during the shutdown sequence that the port is not released properly?
TIA,
Christophe
Similar Messages
-
I built a simple application using LabView 7.1 using serial ports and using VISA . I finish the project and built the installer. on the development PC I test the application (from the "start" menu, and it run correctly. when I try to insall it at another PC (after checking that the appropirate port is valid) I have got an error message "Error 42 occured at Init Serial Port"what could be the reason for this problem
HaimI am using 7.0 but have never used 7.1. But check out this setting. It may help
Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Attachments:
sample.PNG 32 KB -
How can I define the start bit in Serial Port Init VI?
I don't know if the number of start bits of the Serial Port Init VI match with the serial communications requirements of the device I need to communicate with.
Is there any way of modifying this parameter?LabVIEW uses the standard WindowsAPI for all of its serial functions. As such, LabVIEW does not support a customizable start bit since the native serial driver does not.
-
I CAN NOT find serial port init.vi
In labview8.6 , I CAN NOT find serial port init.vi.
Other lots of icon can be found.....Dennis Knutson wrote:
for(imstuck) wrote:
That's because it is called VISA Configure Serial Port. It is located in Instrument I/O->Visa->Visa->Visa Advanced-> Bus Interface Specific -> serial.
And there it is. Sometimes you really gotta dig!
You enjoy taking the long way there?
Message Edited by Dennis Knutson on 05-20-2010 05:48 PM
I just did a search of the palette and thats where it took me so thats what i posted to help the OP. Besides, sometimes the scenic route is nice. You pass lots of beautiful VIs on the way to your destination that you may have never known existed. And, I actually prefer the quick drop way .
Message Edited by for(imstuck) on 05-20-2010 08:35 PM
CLA, LabVIEW Versions 2010-2013 -
I currently use LV to dialog with an RS232 device via the serial port.
How often does I have to re-init he serial port?
For the moment, I do it each time I want to send a string to the device.perform a "dummy" read of the serial port and throw away the data before
sending the serial command.
that way you know the buffer is empty before you expect data.
Stu
"Zen" wrote in message
news:[email protected]..
>
>
> Johannes Niess a écrit :
>
> >
> > In theory: Once. It depends on whether you have an initialisation
> > phase or want to avoid it. If you don't need high speeds, you can
> > leave it the way it is.
>
> I send a string everery two seconds, and raed the reponse from the
> device. I just don't know if the serial buffer is emptied before
> receiving the response string. If not, there might be left old caracters
> causing a wrong response string.
Stu McFarlane
Viewpoint Systems, Inc. -
I have an application that needs to read in a set-length string of 13 data readings seperated by a commas. I have a vi set up that will take the incoming string and seperate it out to its different data points. BUT, when I'm reading in the data over the serial port, I don't know how to wait until I have a complete set of 13 data points before displaying my data. I'm using a vi that extracts doubles from the string to display all 13 data points, and as each point is recieved from my test item, it scrolls through the 13 seperate data displays. All this is placed inside a while loop, so all of my data is coming in, but i'm having trouble seperating it out for display purposes. My test item will be generating the string of 13 floating point numbers seperated by commas at a rate of about 1 set every 1-2 seconds.
Basically, I need advice on how to read in a full string of 13 data points and after the full string is read in, then display them using an extract_from_string vi.
Thanks in advance
jimmyMessage Edited by JMorgan on 03-02-2005 10:50 AMJimmy,
Is the last data point separated by a comma or by some other character from the beginning of the next data set? If it is a different character, like a carriage return, then all you need to do is to search for that character in the received data. If the stream is continuous and no framing character occurs, then you have to count and hope it never gets out of sync.
Lynn -
Using a serial port under j9.. How?
I am trying out j9 on an ipaq. I am trying to get javax.comm to work.
When I call CommPortIdentifier.getIdentifiers ();
I get java.lang.string.NoSuchMethodError: java/lang/String.<init>([BIII)V
It would appear that the javax.comm package was implemented using a now deprecated String method, and that IBM has chosen not to implement deprecated methods in it's j9 vm (I get the same issue trying to run swing.)
One would think that what is needed is an updated javax.comm package. However, there doesn't appear to be a javax.comm package on Sun's site, let alone an updated one. Whats going on here? Can someone give me an idea of how Sun and/or the JCP thinks about developers who want to use serial ports?
Is there a workaround? A different way of talking to a serial port? Or should I abandon j9? I should add that I got my software running just fine on nsi.com's creme vm (javax.comm and swing too) and it worked without any hassles. It even understands jar files (is there a reason why IBM insists on having a link file?). However, the reason I persevered was that a) j9 is cheaper and more importantly b) nsi.com don't seem terribly keen on actually selling their product. I have lots of references to them selling their vm in bundles of 40 ($1000) which is a bit ouchy but hey I'm not paying for it. But, you'd think the nsi.com people would actually confirm this on their site?
So.. can it be done? And why, in the world of embedded systems (my field) and now lots of phones and pdas, is so little attention given to the humble serial port? It doesn't matter how fancy the protocol is, underneath it all is a UART. grumble
-RusselHi Russel,
I will probably soon be in the position you are in trying to get this to work. I found the following page which offers some promise.
http://www.intrinsyc.com/support/I-Linux/405-cube/misc/smf_serial_port_access_example.htm
Mike -
Serial ports not appearing in MAX - VISA installed.
Hi All,
Had a rather strange issue today that I couldn't resolve with serial ports not appearing in MAX (and hence being inaccessible to LabVIEW). Under the windows device manager it shows 4 COM ports and I have verified with an external program that they are functioning correctly.
I had the LabVIEW 2011 SP1 f2 runtime installed, DAQmx 9.6.1 and NI-VISA 5.3 (5.2 also didn't work).
Things I have tried:
- Updating VISA from 5.2 to 5.3
- Reinstalling the COM port devices under device manager
- Changing the COM port numbers
- Verifying that the COM ports are functioning correctly
- Tried adding a USB to Serial converter as a new COM port
- Reinstalling MAX
- Reinstalling NI-VISA
- Reinstalling everything (reboot each time when prompted)
- Resetting the hardware configuration from within MAX
- Run installers / MAX as administrator (this is running from the local admin account)
- Checked that NI-VISA appears under software in MAX
- Repaired MAX/NI-VISA
Is there anything else that could cause the COM ports not to appear in MAX when they appear (and work correctly) in device manager when a reinstall of NI VISA / MAX won't solve?
Certified LabVIEW Architect, Certified TestStand Developer
NI Days (and A&DF): 2010, 2011, 2013, 2014
NI Week: 2012, 2014
Knowledgeable in all things Giant Tetris and WebSockets
Solved!
Go to Solution.I found the solution - it turns out that the serial ports were available to LabVIEW, they just didn't show up in MAX because installing just the runtime does not show the devices in MAX.
Despite doing a lot of googling earlier, it didn't throw up this knowledgebase article until I searched for it under a different phrase - http://digital.ni.com/public.nsf/allkb/766FD80DAE42E52886256A0200619CFE?OpenDocument
Certified LabVIEW Architect, Certified TestStand Developer
NI Days (and A&DF): 2010, 2011, 2013, 2014
NI Week: 2012, 2014
Knowledgeable in all things Giant Tetris and WebSockets -
Function for reading from serial port
Hi experts,
We are trying to read data from the serial port with the following function we got from internet.
The problem is when creating the object with the sentence CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
This returns a sy-subrc = 2 and shows the exception NO_CREATE_OBJECT.
We already copied the file MSCOMM32.OCX in c:\windows\system32 and we successfuly registered it, with regsvr32.exe.
We tried it with Windows XP and Vista.
Anybody has any idea?
Thanks in advance
FUNCTION ZSERIALCOM.
""Interfase local
*" IMPORTING
*" REFERENCE(MODE) TYPE I DEFAULT 0
*" REFERENCE(COMMPORT) TYPE I DEFAULT 1
*" REFERENCE(SETTINGS) TYPE C DEFAULT '2400,N,8,1'
*" REFERENCE(OUTPUT) TYPE C OPTIONAL
*" EXPORTING
*" REFERENCE(INPUT) TYPE C
*" EXCEPTIONS
*" NO_CREATE_OBJECT
TYPE-POOLS: sabc.
INCLUDE ole2incl.
PERFORM init.
PERFORM open_port USING commport settings.
IF mode = 0.
PERFORM read_port
CHANGING input.
ENDIF.
IF mode = 1.
PERFORM write_port
USING output
CHANGING input.
ENDIF.
PERFORM final.
ENDFUNCTION.
DATA: o_obj TYPE ole2_object.
*& Form Init
text
--> p1 text
<-- p2 text
FORM init.
DATA:
wa_repid LIKE sy-repid.
wa_repid = sy-repid.
CALL FUNCTION 'AUTHORITY_CHECK_OLE'
EXPORTING
program = wa_repid
activity = sabc_act_call
application = 'MSCOMMLib.MSComm.1'
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT o_obj '"MSCOMMLib.MSComm.1"'.
IF sy-subrc <> 0.
RAISE no_create_object.
ENDIF.
ENDFORM. " Init
FORM open_port *
--> COMMPORT *
--> SETTINGS *
FORM open_port USING commport settings.
SET PROPERTY OF o_obj 'CommPort' = commport.
SET PROPERTY OF o_obj 'Settings' = settings.
SET PROPERTY OF o_obj 'InputLen' = 0.
SET PROPERTY OF o_obj 'PortOpen' = 1.
ENDFORM. "open_port
FORM read_port *
--> INPUT *
FORM read_port
CHANGING input.
DATA:
wa_buffer TYPE i.
DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
IF wa_buffer > 0.
GET PROPERTY OF o_obj 'Input' = input.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " read_port
FORM write_port *
--> OUTPUT *
FORM write_port
USING output
CHANGING input.
DATA:
wa_buffer TYPE i.
SET PROPERTY OF o_obj 'Output' = output.
DO 10 TIMES.
GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
IF wa_buffer > 0.
GET PROPERTY OF o_obj 'Input' = input.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
*& Form final
text
--> p1 text
<-- p2 text
FORM final.
SET PROPERTY OF o_obj 'PortOpen' = 0.
FREE OBJECT o_obj.
ENDFORM. " finalbligwHi ,
I want to read value form weigh bridge through COMM port. I have developed the FM and done the setting as mentioned in the below link
Read COMM port using ABAP w/o third party software
but while executing the FM independently I am able to get the value from the COMM port,but when I call the FM from a program I am not able to get the output value from the FM.I am calling the FM from the report program.please find the code below.
report test.
data : lv_input TYPE c.
CALL FUNCTION 'ZFM_WEIGHINTERFACE'
EXPORTING
MODE = 0
COMMPORT = 1
SETTINGS = '1200,N,8,1'
OUTPUT = ''
IMPORTING
INPUT = lv_input
EXCEPTIONS
NO_CREATE_OBJECT = 1
OTHERS = 2
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
if I execute the FM independently the output is getting perfectly.but while calling from a program i am facing the issue..
any suggestion is appreciated.
Thanks
Vivek -
Servlet that talks to Serial Port
Everyone,
I am having trouble getting a servlet to talk to a serial port. I am using the Comms extension package from Sun. The servlet fails to initialize and I cannot figure out if it is a security issue or a class loader issue. If it is a security issue can someone tell me a quit and dirty way to turn security off. At this stage, I have control of both client and server and I am not concerned with security. I am using the Sun System Java Application Server 8 to deploy the servlet. Below is the trace
Allocate exception for servlet ModemServletjavax.servlet.ServletException: javax/comm/SerialPortEventListener at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:286) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:115) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:997) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:670) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:150) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:214) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:168) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:133) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:539) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at com.sun.enterprise.webservice.EjbWebServiceValve.invoke(EjbWebServiceValve.java:134) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at com.sun.enterprise.security.web.SingleSignOn.invoke(SingleSignOn.java:254) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at com.sun.enterprise.web.VirtualServerValve.invoke(VirtualServerValve.java:209) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:114) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at com.sun.enterprise.web.VirtualServerMappingValve.invoke(VirtualServerMappingValve.java:166) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:936) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:165) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:683) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:604) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:542) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:647) at java.lang.Thread.run(Thread.java:534)----- Root Cause -----java.lang.NoClassDefFoundError: javax/comm/SerialPortEventListener at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1732) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:904) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1370) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at ModemServlet.init(ModemServlet.java:21) at javax.servlet.GenericServlet.init(GenericServlet.java:261) at sun.reflect.GeneratedMethodAccessor169.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:246) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:500) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:268) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:115) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:997) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:670) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:150) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:214) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:168) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:144) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:133) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:539) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at com.sun.enterprise.webservice.EjbWebServiceValve.invoke(EjbWebServiceValve.java:134) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at com.sun.enterprise.security.web.SingleSignOn.invoke(SingleSignOn.java:254) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at com.sun.enterprise.web.VirtualServerValve.invoke(VirtualServerValve.java:209) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:114) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:109) at com.sun.enterprise.web.VirtualServerMappingValve.invoke(VirtualServerMappingValve.java:166) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:107) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:522) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:936) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:165) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:683) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:604) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:542) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:647) at java.lang.Thread.run(Thread.java:534)You could try and open up the permissions on the appserver and see if the error goes away as a test. You can do this by editing the domains/domain1/config/server.policy, saving the file and restarting the app server.
-
RxtxSerial library multiple serial ports listener
Hello All,
I am using rxtxSerial library (import gnu.io.*; compatible with previousely available from Sun import javax.comm.*;) for my bridge application. Th example provided in the library's web site with nulltest.java employs only one serial port. It is powerful since it is threaded and detects incomming/outgoing streams.
However, I would like to bridge between servers so multiple ports will be employed. Do you heave any suggestion how to obtain multiple port handling (reading/writing) within the same class. The null test code is presented as follows. Simplest idea is to use arrays, but more details are required.
// derived from SUN's examples in the javax.comm package
import java.io.*;
import java.util.*;
//import javax.comm.*; // for SUN's serial/parallel port libraries
import gnu.io.*; // for rxtxSerial library
public class nulltest implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static CommPortIdentifier saveportId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
static String messageString = "AT";
static OutputStream outputStream;
static boolean outputBufferEmptyFlag = false;
public static void main(String[] args) {
boolean portFound = false;
String defaultPort;
// determine the name of the serial port on several operating systems
String osname = System.getProperty("os.name","").toLowerCase();
if ( osname.startsWith("windows") ) {
// windows
defaultPort = "COM5";
} else if (osname.startsWith("linux")) {
// linux
defaultPort = "/dev/ttyS0";
} else if ( osname.startsWith("mac") ) {
// mac
defaultPort = "????";
} else {
System.out.println("Sorry, your operating system is not supported");
return;
if (args.length > 0) {
defaultPort = args[0];
System.out.println("Set default port to "+defaultPort);
// parse ports and if the default port is found, initialized the reader
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
System.out.println("Found port: "+defaultPort);
portFound = true;
// init reader thread
nulltest reader = new nulltest();
if (!portFound) {
System.out.println("port " + defaultPort + " not found.");
public void initwritetoport() {
// initwritetoport() assumes that the port has already been opened and
// initialized by "public nulltest()"
try {
// get the outputstream
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
// activate the OUTPUT_BUFFER_EMPTY notifier
serialPort.notifyOnOutputEmpty(true);
} catch (Exception e) {
System.out.println("Error setting event notification");
System.out.println(e.toString());
System.exit(-1);
public void writetoport() {
System.out.println("Writing \""+messageString+"\" to "+serialPort.getName());
try {
// write string to serial port
outputStream.write(messageString.getBytes());
} catch (IOException e) {}
public nulltest() {
// initalize serial port
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}
// activate the DATA_AVAILABLE notifier
serialPort.notifyOnDataAvailable(true);
try {
// set port parameters
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
// start the read thread
readThread = new Thread(this);
readThread.start();
public void run() {
// first thing in the thread, we initialize the write operation
initwritetoport();
try {
while (true) {
// write string to port, the serialEvent will read it
writetoport();
Thread.sleep(1000);
} catch (InterruptedException e) {}
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
// we get here if data has been received
byte[] readBuffer = new byte[20];
int numBytes = 0;
try {
// read data
while (inputStream.available() > 0) {
numBytes = inputStream.read(readBuffer);
// print data
String result = new String(readBuffer);
System.out.println("Bytes read: "+numBytes+", Read contents: "+result);
} catch (IOException e) {}
break;
}Kujtim
Edited by: Kujtim on Jul 12, 2009 1:41 PM
Edited by: Kujtim on Jul 12, 2009 1:43 PM
Edited by: Kujtim on Jul 13, 2009 1:57 PMAs an off the wall suggestion, check the usb "power save settings" under "control Panelower Options:Edit Plan Settings:Advanced Settings:USB settings" You want the USB selective suspend setting to be Disabled. Another possible idagnostic tool might be to do a Power Efficiency Diagnostics Report which we have found has occasionally pointed us to usb hanging issues.
Using the same type usb-serial adapters doesn't guarantee anything, but I have run into issues where a vendor's driver was implemented incorrectly. It ended up being a wrapper around the FTDI driver, and the wrapper dll wasn't correctly made multi-threaded safe. I browbeat the vendor (I was working at a LARGE corporation, with a prospective LARGE purchase of the devices) into telling me what calls their wrapper made. I then used the FTDI dll directly, not using the "simplified interface" of the vendor's dll. FTDI's dll was thread safe, no more random lockups/BSOD.
Good Luck, these are incredibly painful!
Putnam
Certified LabVIEW Developer
Senior Test Engineer
Currently using LV 6.1-LabVIEW 2012, RT8.5
LabVIEW Champion -
Unable to capture data from Serial port using LVRT2010 in single core pentium 4 machine
I am using application written in Labview using windows Labview
Runtime environment 2010. Application creates a tunnel to intercept data from
Serial port.
My problem is, Currently, I am using single core Pentium
processor. When I am trying to intercept the data between COM1 and COM7 (COM 7
is a virtual port) it is not able to capture data.
When I am running Labview RT environment using dual core
processor machine it is running normally. I wonder whether it could be the compatibility issues with
single core Pentium processor.Hi Magnetica
Are both of the machines running the same runtime engine,
drivers ect?
Have you had RT applications running on this
machine before?
Is the development computer a 64bit machine?
The processor is a supported model (See link below).
http://zone.ni.com/devzone/cda/tut/p/id/8239
Regards
Robert
National Instruments UK & Ireland -
KM2M serial port not working in Linux
I noticed a few Linux postings so I thought I'd give this a shot. I'm running Fedora Core and for some strange reason I can't seem to send any communications out to the ttyS0 (COM 1) or ttyS1 (COM 2) ports.
Does anyone have any suggestions on making it work?
Thank you.No, your code had no termination characters at all - automatic or not. The enable termination character for the VISA Configure Serial Port is only for reads. Just like the help explains.
And while you should check the download page for updates, LabVIEW comes with the 34401 driver.
Message Edited by Dennis Knutson on 12-19-2009 05:49 PM -
Java ME 8 Permission check failed when opening a serial port
I have a larger Jave ME8.1 application that was going well until I tried to add one last piece, reading and writing data from a serial port. This was left to last because it is trivial, at least in most programming languages. The is IDE NetBeans 8.0.2 running on a Windows 7 PC. The platform is a Raspberry Pi B or B+ (I have tried both) with the most current Raspbian (12/24/2014 I believe). To simplify the process I created a new app with just the open and close code and this generates the same error I am experiencing in the larger application. The program is as follows:
package javamecomapp;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.microedition.io.CommConnection;
import javax.microedition.io.Connector;
import javax.microedition.midlet.MIDlet;
* @author ****
public class JavaMEcomApp extends MIDlet {
static int BAUD_RATE = 38400;
static String SERIAL_DEVICE = "ttyAMA0";
static CommConnection commConnection = null;
static OutputStream os = null;
static InputStream is = null;
static String connectorString;
private int rtnValue = -1;
@Override
public void startApp() {
java.lang.System.out.println("Opening comm port.");
try {
rtnValue = JavaMEcomApp.openComm();
} catch (IOException ex) {
Logger.getLogger(JavaMEcomApp.class.getName()).log(Level.SEVERE, null, ex);
@Override
public void destroyApp(boolean unconditional) {
java.lang.System.out.println("Closing comm port.");
try {
rtnValue = JavaMEcomApp.closeComm();
} catch (IOException ex) {
Logger.getLogger(JavaMEcomApp.class.getName()).log(Level.SEVERE, null, ex);
private static int openComm()throws IOException {
java.lang.System.out.println("Opening comm port.");
connectorString = "comm:" + SERIAL_DEVICE + ";baudrate=" + BAUD_RATE;
commConnection = (CommConnection)Connector.open(connectorString);
is = commConnection.openInputStream();
os = commConnection.openOutputStream();
return 0;
private static int closeComm()throws IOException {
java.lang.System.out.println("Closing comm port.");
is.close();
os.close();
commConnection.close();
return 0;
If I comment out the JavaMEcomApp.openComm and closeComm lines it runs fine. When they are included, the following error is dumped to the Raspberry Pi terminal:
Opening comm port.
Opening comm port.
[CRITICAL] [SECURITY] iso=2:Permission check failed: javax.microedition.io.CommProtocolPermission "comm:ttyAMA0;baudrate=38400" ""
TRACE: <at java.security.AccessControlException: >, startApp threw an Exception
java.security.AccessControlException:
- com/oracle/meep/security/AccessControllerInternal.checkPermission(), bci=118
- java/security/AccessController.checkPermission(), bci=1
- com/sun/midp/io/j2me/comm/Protocol.checkForPermission(), bci=16
- com/sun/midp/io/j2me/comm/Protocol.openPrim(), bci=31
- javax/microedition/io/Connector.open(), bci=77
- javax/microedition/io/Connector.open(), bci=6
- javax/microedition/io/Connector.open(), bci=3
- javamecomapp/JavaMEcomApp.openComm(), bci=46
- javamecomapp/JavaMEcomApp.startApp(), bci=9
- javax/microedition/midlet/MIDletTunnelImpl.callStartApp(), bci=1
- com/sun/midp/midlet/MIDletPeer.startApp(), bci=5
- com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=246
- com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
- com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
- com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
- com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
java.security.AccessControlException:
- com/oracle/meep/security/AccessControllerInternal.checkPermission(), bci=118
- java/security/AccessController.checkPermission(), bci=1
- com/sun/midp/io/j2me/comm/Protocol.checkForPermission(), bci=16
- com/sun/midp/io/j2me/comm/Protocol.openPrim(), bci=31
- javax/microedition/io/Connector.open(), bci=77
- javax/microedition/io/Connector.open(), bci=6
- javax/microedition/io/Connector.open(), bci=3
- javamecomapp/JavaMEcomApp.openComm(), bci=46
- javamecomapp/JavaMEcomApp.startApp(), bci=9
- javax/microedition/midlet/MIDletTunnelImpl.callStartApp(), bci=1
- com/sun/midp/midlet/MIDletPeer.startApp(), bci=5
- com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=246
- com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
- com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
- com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
- com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
Closing comm port.
Closing comm port.
TRACE: <at java.lang.NullPointerException>, destroyApp threw an Exception
java.lang.NullPointerException
- javamecomapp/JavaMEcomApp.closeComm(), bci=11
- javamecomapp/JavaMEcomApp.destroyApp(), bci=9
- javax/microedition/midlet/MIDletTunnelImpl.callDestroyApp(), bci=2
- com/sun/midp/midlet/MIDletPeer.destroyApp(), bci=6
- com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=376
- com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
- com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
- com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
- com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
java.lang.NullPointerException
- javamecomapp/JavaMEcomApp.closeComm(), bci=11
- javamecomapp/JavaMEcomApp.destroyApp(), bci=9
- javax/microedition/midlet/MIDletTunnelImpl.callDestroyApp(), bci=2
- com/sun/midp/midlet/MIDletPeer.destroyApp(), bci=6
- com/sun/midp/midlet/MIDletStateHandler.startSuite(), bci=376
- com/sun/midp/main/AbstractMIDletSuiteLoader.startSuite(), bci=38
- com/sun/midp/main/CldcMIDletSuiteLoader.startSuite(), bci=5
- com/sun/midp/main/AbstractMIDletSuiteLoader.runMIDletSuite(), bci=130
com/sun/midp/main/AppIsolateMIDletSuiteLoader.main(), bci=26
I have tried this with three different serial ports, /dev/ttyAMA0 (yes I did disable the OS from using it), an arduino board /dev/ttyACM0, and a USB to RS485 adaptor /dev/ttyUSB0. All of these ports could be connected and use normally with both a C program and terminal program in the Pi. The API Permissions were set in the project properties / Application Descriptor / API Permissions to jdk.dio.DeviceMgmtPermission "/dev/ttyAMA0". This of course was changed as I tested different devices.
I found a reference suggesting adding the line "authentication.provider = com.oracle.meep.security.NullAuthenticationProvider" to the end of the jwc_properties.ini file. This had no effect. I found references that during development in eclipse and NetBeans, the app is already elevated to the top level so this should not be an issue until deployment. This does not appear to be the case.
I am out of time and need a solution quickly. Any suggestions are welcome.Terrence,
Thank you for responding and confirming the issues I'm having with static addressing. As far as the example above, I do have the standard LEDs working correctly, however, the example I'm referring to above is from the JavaME samples using the GPIO Port for the LEDS, according to the Device I/O Preconfigured List you referenced:
GPIO Ports
The following GPIO ports are preconfigured.
Devicel ID
Device Name
Mapped
Configuration
8
LEDS
PTB22
PTE26
PTB21
direction = 1 (Output only)
initValue = 0
GPIOPins:
controllerNumber = 1
pinNumber = 22
mode = 4 (Push-pull mode)
controllerNumber = 4
pinNumber = 26
mode = 4 (Push-pull mode)
controllerNumber = 1
pinNumber = 21
mode = 4 (Push-pull mode)
So is the assumption that using GPIOPort for accessing the GPIO port for Device ID 8 as listed in the Device I/O Preconfigured list not supported? -
Writing to serial port 1 from a PDA
ok this program is driving me NUTS! i have this microchip which uses a certain protocol... now this protocol requires that you send it some characters in hexadecimal so it'll reset... afterwhich it'll send you a data packet containing the version of the microchip etc etc (it's an aduc812... which you can find on www.analog.com)... anyway, that's not important... i am having trouble actually WRITING to serial port 1... i noticed that doing it through an actual PC requires some sort of "open serial port.vi" which is not available in the pda version... all i have is init.vi which is apparently not enough from what i am told... i thas to be opened first... initialized next... then written to then read from... does anyone know how i can acc
omplish this open procedure with the pda module? is that some sort of software i'm missing? why isn't it included with the pda module add on... etc etc... thank you in advance... i really need help with this so as much information as possible would be appreciated... let me know if you need further info...
christinaHey Christina,
Here is a link to a knowledge base one simply writing to the serial port from a PDA.
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=E011F478861443EFE034080020E74861&p_node=%20DZ52363&p_source=External
Hope this helps.
Brett
Maybe you are looking for
-
Can no longer print directly from html nor to a pdf. Mac OX 10.7.4
For several weeks now whenever I try to print a document directly from Internet (html) the printer preview window doesn't show the document. I only get a black screen. I tried printing anyway thinking that there could be a problem with the preview se
-
i have a specific requirment 1. need to send notification to multiple user using PO approval 2. send po has been approved mail to requester and receiver 3. need to send notification remainder mail after po is created
-
I'd love to see an icon to indicate text is embedded in an event
Currently, there is no quick way to know that text is embedded in an event in iCal. An icon, such as a small box, would be exceptional to indicate there is text embedded in the icon. Right now, you have to open any event to find out if there is a not
-
How can I buy my "wish list" ?
I have 14 tunes in my wish list and I don't know how tu buy them . Do I have to select them one by one again and choose "buy" instead of "wish list" or can I buy them BY the wish list ?
-
Hello, I'm trying to create a select which has 5 different tables and i'm getting the following error: Exception [TOPLINK-6015] (Oracle TopLink Essentials - 2006.4 (Build 060412)): oracle.toplink.essentials.exceptions.QueryException Exception Descrip