Problem in using serial port.
I am using serial port to get data from a fusion splicer. The number of bytes at the port is 4096 but the read buffer of VISA read is empty. I am reading the same number of bytes. Can any one tell me what is the maximum size of VISA Read buffer? I am trying to put the contents of the buffer in a file. I am using labVIEW 6.1 on linux.I am also attaching the VI.
I also noticed this problem...If I read the number of bytes in the serial buffer many times, sometimes it reads it as 0 and I have to keep trying until it reads this 4096 bytes.
Thanx for any help.
S.Vijayalakshmi
Attachments:
serail_comm.vi 52 KB
Hey Viji,
In your application it looks like you are just checking to see how many bytes are at the serial port. Is it possible that your application is check for the serial data at the port before the data actually gets there. If you are looping this code as a subVI or just running it over and over it is possible that one of the iterations could occur faster than your device can write the information to the bus. In this instance you are checking the number of bytes at the port and there might not be any there yet. In this case the port reads 0 as you have designed it.
If you want the read function to wait and always read 4096 then don't wire the bytes at port to the read function. Just wire a constant/control equal to 4096 to the read function instead o
f the bytes at port. In this case, if there are not any bytes at the port the read function will wait for the bytes to show up or until the timeout period is reached.
I would also, suggest lowering your time to something more reasonable, because if your instrument quits transmitting your application is going to wait for 33 minutes. That is a long time for a program to hang.
I hope this helps out.
JoshuaP
National Instruments
Similar Messages
-
Kernel Panic when I use Serial Port
Hello,
I have a macbook pro 15" 2.66 Ghz 2009 running Mountain Lion.
I use Serial Ports for communicate with instruments via Matlab or CoolTerm, using bluetooth or USB. After some minute of work, my computer crash for kernel panic.
This is the log file about a crash with matlab and bluetooth, someone can help me?
Thanks in advance
Gildo
Wed Dec 19 11:59:55 2012
panic(cpu 0 caller 0xffffff8010a43d5b): "a freed zone element has been modified in zone: kalloc.1024"@/SourceCache/xnu/xnu-2050.18.24/osfmk/kern/zalloc.c:214
Backtrace (CPU 0), Frame : Return Address
0xffffff812c78b3a0 : 0xffffff8010a1d626
0xffffff812c78b410 : 0xffffff8010a43d5b
0xffffff812c78b450 : 0xffffff8010a435d2
0xffffff812c78b530 : 0xffffff8010a245ed
0xffffff812c78b560 : 0xffffff8010e22ca2
0xffffff812c78b580 : 0xffffff7f91e9b3ac
0xffffff812c78b6c0 : 0xffffff7f91dd21bd
0xffffff812c78b7f0 : 0xffffff7f91dc59aa
0xffffff812c78b9f0 : 0xffffff7f91dcba58
0xffffff812c78bad0 : 0xffffff7f91decfb3
0xffffff812c78bb40 : 0xffffff7f91decf2f
0xffffff812c78bbb0 : 0xffffff7f91e805c4
0xffffff812c78bbf0 : 0xffffff8010e47d9a
0xffffff812c78bc50 : 0xffffff7f91e81604
0xffffff812c78bc70 : 0xffffff7f91e7df64
0xffffff812c78bca0 : 0xffffff7f91c4c525
0xffffff812c78bce0 : 0xffffff7f91c4a036
0xffffff812c78bd10 : 0xffffff8010b1fe0c
0xffffff812c78bd50 : 0xffffff8010b24c56
0xffffff812c78bda0 : 0xffffff8010b11c96
0xffffff812c78bde0 : 0xffffff8010b094af
0xffffff812c78be10 : 0xffffff8010b08645
0xffffff812c78be60 : 0xffffff8010d4c56c
0xffffff812c78bed0 : 0xffffff8010d48b6f
0xffffff812c78bf20 : 0xffffff8010d4af60
0xffffff812c78bf50 : 0xffffff8010de182a
0xffffff812c78bfb0 : 0xffffff8010aced33
Kernel Extensions in backtrace:
com.apple.iokit.IOBluetoothFamily(4.0.9f33)[1C326A11-ADF7-353E-AD41-458D6A886E0 5]@0xffffff7f91db7000->0xffffff7f91e57fff
dependency: com.apple.iokit.IOUSBFamily(5.4.0)[C3094550-7F58-3933-A4F7-CD33AE83F8B9]@0xffff ff7f910ea000
com.apple.iokit.IOSerialFamily(10.0.6)[0165A9A0-F112-366C-9D82-EFC7344274F0]@0x ffffff7f91c49000->0xffffff7f91c56fff
com.apple.iokit.IOBluetoothSerialManager(4.0.9f33)[6B6E14A7-7A68-3291-BFFF-F972 4D5B50FA]@0xffffff7f91e7b000->0xffffff7f91e84fff
dependency: com.apple.iokit.IOSerialFamily(10.0.6)[0165A9A0-F112-366C-9D82-EFC7344274F0]@0x ffffff7f91c49000
com.apple.iokit.AppleBluetoothHCIControllerUSBTransport(4.0.9f33)[867D6939-4D49 -3149-A1A5-380C236C8D12]@0xffffff7f91e8f000->0xffffff7f91eb5fff
dependency: com.apple.iokit.IOUSBFamily(5.4.0)[C3094550-7F58-3933-A4F7-CD33AE83F8B9]@0xffff ff7f910ea000
dependency: com.apple.iokit.IOACPIFamily(1.4)[A35915E8-C1B0-3C0F-81DF-5515BC9002FC]@0xfffff f7f90ff2000
dependency: com.apple.iokit.IOPCIFamily(2.7.2)[B1B77B26-7984-302F-BA8E-544DD3D75E73]@0xffff ff7f910af000
BSD process name corresponding to current thread: MATLAB
Mac OS version:
12C60
Kernel version:
Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64
Kernel UUID: 69A5853F-375A-3EF4-9247-478FD0247333
Kernel slide: 0x0000000010800000
Kernel text base: 0xffffff8010a00000
System model name: MacBookPro5,3 (Mac-F22587C8)
System uptime in nanoseconds: 4765863445501
last loaded kext at 2974523021770: com.apple.filesystems.smbfs 1.8 (addr 0xffffff7f91019000, size 229376)
last unloaded kext at 34978808166: com.parallels.kext.prl_usb_connect 7.0 15104.778994 (addr 0xffffff7f9114c000, size 28672)
loaded kexts:
com.nvidia.CUDA 1.1.0
org.virtualbox.kext.VBoxNetAdp 4.0.4
org.virtualbox.kext.VBoxNetFlt 4.0.4
org.virtualbox.kext.VBoxUSB 4.0.4
org.virtualbox.kext.VBoxDrv 4.0.4
com.parallels.kext.prl_vnic 7.0 15104.778994
com.parallels.kext.prl_netbridge 7.0 15104.778994
com.parallels.kext.prl_hid_hook 7.0 15104.778994
com.parallels.kext.prl_hypervisor 7.0 15104.778994
com.parallels.kext.prl_usb_connect 7.0 15104.778994
com.logmein.driver.LogMeInSoundDriver 1.0.0
at.obdev.nke.LittleSnitch 3854
com.apple.filesystems.smbfs 1.8
com.apple.driver.AppleUSBCDC 4.1.22
com.apple.driver.AppleHWSensor 1.9.5d0
com.apple.driver.AppleTyMCEDriver 1.0.2d2
com.apple.driver.AGPM 100.12.69
com.apple.driver.AppleHDAHardwareConfigDriver 2.3.1f2
com.apple.driver.AppleHDA 2.3.1f2
com.apple.driver.AppleMikeyHIDDriver 122
com.apple.filesystems.autofs 3.0
com.apple.driver.AudioAUUC 1.60
com.apple.driver.AppleSMCLMU 2.0.2d0
com.apple.driver.AppleBacklight 170.2.3
com.apple.driver.AppleMikeyDriver 2.3.1f2
com.apple.driver.AppleMuxControl 3.2.11
com.apple.driver.ACPI_SMC_PlatformPlugin 1.0.0
com.apple.driver.AppleLPC 1.6.0
com.apple.iokit.IOBluetoothUSBDFU 4.0.9f33
com.apple.iokit.BroadcomBluetoothHCIControllerUSBTransport 4.0.9f33
com.apple.driver.AppleUpstreamUserClient 3.5.10
com.apple.driver.AppleMCCSControl 1.0.33
com.apple.GeForce 8.0.0
com.apple.iokit.IOUserEthernet 1.0.0d1
com.apple.iokit.IOBluetoothSerialManager 4.0.9f33
com.apple.Dont_Steal_Mac_OS_X 7.0.0
com.apple.driver.ApplePolicyControl 3.2.11
com.apple.driver.SMCMotionSensor 3.0.2d6
com.apple.driver.AppleUSBTCButtons 235.4
com.apple.driver.AppleFileSystemDriver 3.0.1
com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0d1
com.apple.BootCache 34
com.apple.driver.AppleUSBTCKeyEventDriver 235.4
com.apple.driver.AppleUSBTCKeyboard 235.4
com.apple.driver.AppleIRController 320.15
com.apple.driver.AppleUSBCardReader 3.1.0
com.apple.iokit.SCSITaskUserClient 3.5.1
com.apple.driver.XsanFilter 404
com.apple.iokit.IOAHCIBlockStorage 2.2.2
com.apple.driver.AppleFWOHCI 4.9.6
com.apple.driver.AppleAHCIPort 2.4.1
com.apple.driver.AirPort.Brcm4331 602.15.22
com.apple.nvenet 2.0.19
com.apple.driver.AppleUSBHub 5.2.5
com.apple.driver.AppleEFINVRAM 1.6.1
com.apple.driver.AppleUSBEHCI 5.4.0
com.apple.driver.AppleUSBOHCI 5.2.5
com.apple.driver.AppleSmartBatteryManager 161.0.0
com.apple.driver.AppleRTC 1.5
com.apple.driver.AppleHPET 1.7
com.apple.driver.AppleACPIButtons 1.6
com.apple.driver.AppleSMBIOS 1.9
com.apple.driver.AppleACPIEC 1.6
com.apple.driver.AppleAPIC 1.6
com.apple.driver.AppleIntelCPUPowerManagementClient 196.0.0
com.apple.nke.applicationfirewall 4.0.39
com.apple.security.quarantine 2
com.apple.driver.AppleIntelCPUPowerManagement 196.0.0
com.apple.driver.AppleBluetoothHIDKeyboard 165.5
com.apple.driver.AppleHIDKeyboard 165.5
com.apple.driver.AppleBluetoothHIDMouse 175.8
com.apple.driver.AppleHIDMouse 175.8
com.apple.driver.IOBluetoothHIDDriver 4.0.9f33
com.apple.driver.DspFuncLib 2.3.1f2
com.apple.kext.triggers 1.0
com.apple.iokit.IOFireWireIP 2.2.5
com.apple.driver.AppleBacklightExpert 1.0.4
com.apple.driver.AppleHDAController 2.3.1f2
com.apple.iokit.IOHDAFamily 2.3.1f2
com.apple.driver.AppleSMBusPCI 1.0.10d0
com.apple.driver.IOPlatformPluginLegacy 1.0.0
com.apple.driver.IOPlatformPluginFamily 5.2.0d16
com.apple.iokit.AppleBluetoothHCIControllerUSBTransport 4.0.9f33
com.apple.driver.AppleSMBusController 1.0.10d0
com.apple.nvidia.nv50hal 8.0.0
com.apple.NVDAResman 8.0.0
com.apple.iokit.IOAudioFamily 1.8.9fc10
com.apple.kext.OSvKernDSPLib 1.6
com.apple.iokit.IOSurface 86.0.3
com.apple.iokit.IOSerialFamily 10.0.6
com.apple.iokit.IOBluetoothFamily 4.0.9f33
com.apple.driver.AppleGraphicsControl 3.2.11
com.apple.iokit.IONDRVSupport 2.3.5
com.apple.iokit.IOGraphicsFamily 2.3.5
com.apple.driver.AppleSMC 3.1.4d2
com.apple.driver.AppleUSBMultitouch 235.7
com.apple.iokit.IOUSBHIDDriver 5.2.5
com.apple.iokit.IOSCSIBlockCommandsDevice 3.5.1
com.apple.iokit.IOUSBMassStorageClass 3.5.0
com.apple.driver.AppleUSBMergeNub 5.2.5
com.apple.driver.AppleUSBComposite 5.2.5
com.apple.iokit.IOSCSIMultimediaCommandsDevice 3.5.1
com.apple.iokit.IOBDStorageFamily 1.7
com.apple.iokit.IODVDStorageFamily 1.7.1
com.apple.iokit.IOCDStorageFamily 1.7.1
com.apple.iokit.IOAHCISerialATAPI 2.5.0
com.apple.iokit.IOSCSIArchitectureModelFamily 3.5.1
com.apple.iokit.IOFireWireFamily 4.5.5
com.apple.iokit.IOAHCIFamily 2.2.1
com.apple.iokit.IO80211Family 500.15
com.apple.iokit.IONetworkingFamily 3.0
com.apple.iokit.IOUSBUserClient 5.2.5
com.apple.driver.NVSMU 2.2.9
com.apple.iokit.IOUSBFamily 5.4.0
com.apple.driver.AppleEFIRuntime 1.6.1
com.apple.iokit.IOHIDFamily 1.8.0
com.apple.iokit.IOSMBusFamily 1.1
com.apple.security.sandbox 220
com.apple.kext.AppleMatch 1.0.0d1
com.apple.security.TMSafetyNet 7
com.apple.driver.DiskImages 344
com.apple.iokit.IOStorageFamily 1.8
com.apple.driver.AppleKeyStore 28.21
com.apple.driver.AppleACPIPlatform 1.6
com.apple.iokit.IOPCIFamily 2.7.2
com.apple.iokit.IOACPIFamily 1.4
com.apple.kec.corecrypto 1.0Any or all of the following third-party system modifications may be contributing to your problem:
CUDA
VirtualBox
Parallels
LogMeIn
LittleSnitch
If the panic is recurrent, I suggest you uninstall all of them according to the developers' instructions, reboot, and see whether there's any improvement. If there is, you can experiment with putting them back, one at a time, to identify which one is at fault. -
Send command to modem using serial port and capture the response in the labview
hello.
I am doing my shool project.
I want to send command to modem using serial port and get the response in the labview.
When i run my program and enter"AT", only messy code will be displayed.
can anyone help me? thanksDora0512 wrote:
Thanks for you all. My partner got it already.
I am doing send sms part.
Can anyone tell me why my program is not so steadily?
It means this program can run. But somtimes I cannot receive sms. sometimes can
Basically, it is not well-written from both a LabVIEW and a communications point of view. Unfortunately, I can't elaborate because today is an exrtremely busy day at work. I'm hoping this bump will prompt someone to help you with your problem. If you could also provide us with the programmer's guide or the manual for your equipment, that would be extremely helpful.
Bill
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all. -
X4200 - static IP configuration error (using serial port)
I try to setup a static IP address of ILOM on a Sun X4200 server using serial port
After login as root I use command from manual:
set /SP/network pendingipaddress=192.168.2.123 pendingipnetmask=255.255.255.0 pendingipgateway=192.168.2.1 pendingipdiscovery=static commitpending=true
but system say
"invalid command syntax"
Usage: set [target] <property>=value> [<property>=<value>...]
Problem is with "commitpending" command but i don't know why, anyone know the possible reason?
Sincerrelyy
Cyprian SawickiI try to setup a static IP address of ILOM on a Sun X4200 server using serial port
After login as root I use command from manual:
set /SP/network pendingipaddress=192.168.2.123 pendingipnetmask=255.255.255.0 pendingipgateway=192.168.2.1 pendingipdiscovery=static commitpending=true
but system say
"invalid command syntax"
Usage: set [target] <property>=value> [<property>=<value>...]
Problem is with "commitpending" command but i don't know why, anyone know the possible reason?
Sincerrelyy
Cyprian Sawicki -
I pull fiftyfour bytes of data from MicroProcessor's EEPROM using serial port. It works fine. I then send a request for 512 bytes and my "read" goes into loop condition, no bytes are delivered and system is lost
Hello,
You mention that you send a string to the microprocessor that tells it how many bytes to send. Instead of requesting 512 bytes, try reading 10 times and only requesting about 50 bytes at a time.
If that doesn�t help, try directly communicating with your microprocessor through HyperTerminal. If you are not on a Windows system, please let me know. Also, if you are using an NI serial board instead of your computer�s serial port, let me know.
In Windows XP, go to Start, Programs, Accessories, Communications, and select HyperTerminal.
Enter a name for the connection and click OK.
In the next pop-up dialog, choose the COM port you are using to communicate with your device and click OK.
In the final pop
-up dialog, set the communication settings for communicating with your device.
Type the same commands you sent through LabVIEW and observe if you can receive the first 54 bytes you mention. Also observe if data is returned from your 512 byte request or if HyperTerminal just waits.
If you do not receive the 512 byte request through HyperTerminal, your microprocessor is unable to communicate with your computer at a low level. LabVIEW uses the same Windows DLLs as HyperTerminal for serial communication. Double check the instrument user manual for any additional information that may be necessary to communicate.
Please let me know the results from the above test in HyperTerminal. We can then proceed from there.
Grant M.
National Instruments -
Dear All
Can classic bluetooth (v2.1) based accessory using Serial Port Profile (SPP) communicate with all iPhones or iPads ?
Is MFi chip required by a classic bluetooth(v2.1) accessory to communiate with iPhone or iPad over Serial Port Profile ?
Thanks
ManjuDue to a copy/paste glitch, some necessary spaces have inadvertently been removed. If I could fix this, I would.
-
Problem in Accessing serial port using java comm Api
I have installed java comm Api in my pc.
i have gone through the instalation instruction which comes on this package.
I have done the instalation like this
Copy win32com.dll to my <JDK>\bin directory.
Copy comm.jar to my <JDK>\lib directory.
Copy javax.comm.properties to my <JDK>\lib directory.
and restart the system.
But when i run the BlackBox , it is giving me message
"serial port not found".
Can any one tell me , what is the exact problem ?I'm not sure what you mean by BlackBox, but I have used the COMM api extensively.
The majority of problems is that the api cannot see the serial port (which is what you are describing) and this is caused by incorrect placing of the javax.comm.properties file.
As well as <JDK>\lib, try putting it into <JRE>\lib as well. That has often solved problems on my setup. -
Error 37 using serial port with an executable file
Hi all,
I have developed a VI that controls a setellite receiver using RS232
serial port (LabVIEW 5.1.1).
The VI program run properly, but when I compile it and try to run the
executable file I receive an "Error 37, Device not found" error message.
I have already put serpdrv and my_file.ini files in the same directory
of my executable program my_file.exe, but I have not been able to solve
the problem.
Any help greatly appreciated.
Regards
Antonio
Sent via Deja.com http://www.deja.com/
Before you buy.[email protected] wrote:
>
> Hi all,
> I have developed a VI that controls a setellite receiver using RS232
> serial port (LabVIEW 5.1.1).
> The VI program run properly, but when I compile it and try to run the
> executable file I receive an "Error 37, Device not found" error message.
> I have already put serpdrv and my_file.ini files in the same directory
> of my executable program my_file.exe, but I have not been able to solve
> the problem.
> Any help greatly appreciated.
>
> Regards
>
> Antonio
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Maybe you used the serpdrv from an older version of LV
Regards, Roland
Roland Lampka - Nortel Dasa - ESN 565-7257 - FAX 8160 -
My Application gets Error 37 when using Serial Port VIs.
My Application works fine developed with LV 6.1. Then I updated to LV 7.1 and now the Executable of my application gets error 37 when using the old serial port functions. The "serpdrv" file is located in the application directory and is from 02/2002. The application runs well in the development environment after I placed the "serpdrv" file in the LabView directory. I tried to put a line with "serialDevices=..." in the .ini-file of my application but this did not cause an improvement. I also tried to rebuild the EXE with this line in the "labview.ini" file but nothing changes.
Does anybody have another idea ?
Many thanks for help
Thomas>Did you actually replace the old serial functions that come with 7.1 with the functions from 6.1?
Yes. E.g. "open serial driver.vi" uses "open device" with "serpdrv" as device string.
I had the same problem running my application as VI´s. After the copy of serpdrv into the LV 7.1 directory everything works fine.
I don´t understand why the application running as a .exe doesn´t find the serpdrv when it is in the same directory....
Nevertheless many thanks for your answer
Thomas -
Everyone,
I am having trouble getting a servlet to access a serial port. I am deploying to Sun Application Server 8. I am using the Sun Java Communications API for the serial communications. When I downloaded the Comms API, the readme described three steps to integrate the API into the Java environment.
1.) Copy these files into the bin directory of the JRE
win21com.dll
2.) Copy these files into the lib directory of the JRE
comm.jar
javax.comm.properties
3.) Add the path to comm.jar to the CLASSPATH environment variable
This works great for a standalone application but I cannot get it to work in a servlet container.
At first, the servlet could not find the Comm API classes. I solved this problem by integrating the contents of the comm.jar with j2ee.jar. This worked but I would still like to know a better solution. Now the servlet fails to find any serial I/O ports. In the standalone version, this same behavior is caused by not copying the javax.comm.properties into the lib directory of the JRE. I have tried inserting the javax.comm.properties into various places in j2ee.jar with no luck.
The contents of the javax.comm.properties is:
# Drivers loaded by the Java Communications API standard extension
# at initialization time
# Format:
# Each line must contain ONE driver definition only
# Each line must be of the form:
# driver=<ClassName>
# No spaces or tabs in the line.
# ClassName must implement the interface javax.comm.CommDriver
# example: driver=Win32Serial
# The hash(#) character indicates comment till end of line.
# Windows Serial Driver
Driver=com.sun.comm.Win32Driver
I guess the base problem is the the server cannot load the driver.
Any suggestion would be appreciated.
KillBillIf that doesn't work you may need to add your native library to a directory where native code is picked up by the appserver. You may be able to add the java.library.path system property to the java-config element in the domains/domain1/config/domain.xml file and restart the app server.
-
Using Serial Port for Non-Serial Data Acquisiton
I searched the forums and couldn't find anything related to this topic.
I saw that it was possible to use the parallel port for simple digital I/O and I was hoping the serial port can be configured the same. It seems all the VISA VI's only want to use the serial port to recieve ASCII chars at a given baud rate, but is it possible to simply poll the status of the serial line at my own speed to see if it is high or low, kind of like a single pin DAQ?
It seems it would be possible as long as the serial data is read and controlled by labview and not by Windows. Let me know if you have any ideas how to approach this problem, or any feedback as to why it is not possible.
Thanks everyone!
Solved!
Go to Solution.Select Property>Serial Settings>Modem Line Settings. For example, the CTS State is an input to the pc.
Using these lines is a very poor replacement for a scope or DAQ board. The only things you can get back is Asserted, Unasserted, or Unknown. The range of acceptable signals is quite large. Anything between +3 and -3 is an unknown state. Your other signals are +/3 to 15 volts. what kind of signals do you actually want to capture?
edit: There is no such thing as VISA Status so I have no idea what you are actually using.
Message Edited by Dennis Knutson on 07-20-2009 11:09 AM -
Problem communicating via serial port in Linux
Hello,
I am trying to transfer data via serial port, in Linux.
But it is impossible till now!
I get Runtime exception.
Here is my code:
public class Main {
public Main() {
int num=5;
int[] array = new int[5];
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
array[0]=1;
array[1]=2;
array[2]=3;
array[3]=4;
array[4]=5;
new ParallelCommunication(num,array);
import java.io.*;
import java.util.*;
import javax.comm.*; // for SUN's serial/parallel port libraries
//import gnu.io.*; // for rxtxSerial library
public class ParallelCommunication implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static CommPortIdentifier saveportId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
static OutputStream outputStream;
static boolean outputBufferEmptyFlag = false;
int num;
int[] array;
public ParallelCommunication(int this_num,int[] this_array) {
boolean portFound = false;
String defaultPort;
num = this_num;
array=new int[this_array.length];
array = this_array;
// determine the name of the serial port on several operating systems
String osname = System.getProperty("os.name","").toLowerCase();
if ( osname.startsWith("windows") ) {
// windows
defaultPort = "COM1";
} else if (osname.startsWith("linux")) {
// linux
defaultPort = "/dev/ttyS0";
} 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
initialize();
break;
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 void initialize()"
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(int counter) {
try {
// write string to serial port
outputStream.write(String.valueOf(array[counter]).getBytes());
} catch (IOException e) {}
public void initialize() {
// initalize serial port
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {System.out.println("Port In Use.");} //******Here is the Exception******
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();
for(int i=0; i<=num_of_inputs; i++) {
// write string to port, the serialEvent will read it
writetoport(i);
serialPort.close();
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];
try {
// read data
while (inputStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
// print data
String result = new String(readBuffer);
System.out.println("Read: "+result);
} catch (IOException e) {}
break;
}...and the outcome is :
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
Error opening "/dev/ttyS0"
tcgetattr(): Input/output error
at com.sun.comm.LinuxDriver.getCommPort(LinuxDriver.java:66)
at javax.comm.CommPortIdentifier.open(CommPortIdentifier.java:369)
at ParallelCommunication.initialize(ParallelCommunication.java:128)
I have searched a lot and I couldn't find a solution.
Thank you.I'm having the same problem this helped somewhat debug the problem
http://bloggerdigest.blogspot.com/2006/11/linux-serial-com-port-diagnostic-test.html
I'm running Suse 10.3 and apparently it does not recognize my serial ports. So before
you can test your Java code you have to figure out how to make linux see the ports.
If I find a solution I'll let you know but if you find one first let me know. Thanks. -
Using serial port to communicate with servo motor drive
I wish to use Labview 7.1 to control a brushless servo motor with encoder (from MCG) and digital drive (from AMC) via the serial port. The application simply involves progressively loading the shaft on the motor in 180 degree increments, and reading the torque. Is this possible? If so, how complicated is this approach? Thanks!
Communicating with your AMC drive via LabVIEW is no problem. There is an example in the Example Finder (Help >> Find Examples . . ) called Basic Serial Write and Read.vi which will show how to send and receive serial commands. You will have to find out what serial commands your drive responds to by looking at the AMC drive user manual. Certainly there are commands to position your servo motor at various increments and at various speeds.
As for reading torque, however, I would be surprised if the drive would directly output a torque value. One possibility might be to read the current being sent to the servo and then interpret that into a torque reading - provided that the drive has a serial command to read the current output (normally servo motors have a fairly linear current to torque conversion). Current to Torque conversions are motor specific and the accuracy using such a method might not be to good.
A more accurate method would be to use a torque sensor (Transducer Techniques sells these along with many other sensor companies) - or to use a strain gauge. Both types of sensors would need to be read in with a DAQ board (see link for National Instruments DAQ boards).
Hopefully this gives you some ideas - good luck with your project! -
How do I use serial port read and show text, but not have it scroll off screen?
I am new-ish/returning amateur user of Labview and I am trying to edit the example VI "Advanced serial write and read VI" that is part of dev suite 2012. I need to use the string box to show ALL text received from serial port, always appending and only rolls off screen when more real data arrives at serial port.
What is actually happening is as more bytes (or no bytes AT ALL!) arrive during read time, current text rolls off the string box. Even when 0 bytes are received, screen is blanked out. I am not very familiar with functions locations and even worse at understanding obscure references to functions, so please keep replies very basic so I can follow.
Just to be clear, I need the string window to behave like hyperterm does-always shows data and it is not pushed out of window arbitrarily.
Thanks,
Steve
Solved!
Go to Solution.OK- lets start back at the beginning. I have a few questions...
WHy does incoming txt get placed at top of txt box and then scroll up? why would it make more sense to input at the bottom and scroll toward the top. I have created this huge txt box that appears to be impossible to use.
I have attached example of txt boxes I have tried, and pic of VI I have edited. Bad marks for uglyness....
Attachments:
Capture_VI.JPG 117 KB
Capture_VI2.JPG 133 KB -
Problem writing to serial port
Hi All,
I am very new to LabVIEW (just a couple of months). I need to communicate with a serial port of an Advanced Energy RF generator (Ovation) serial port (AE Bus)
The manual talks about little endian conversion, CSR and checksum that I just can't make it work. does anybody know how to write and read to this serial port?
I have used the write and read to serial port from examples with no luck and no response from the generator. I have attached the generator's manual here, the serial commands section starts at page 65 (4-25)
Has anybody written a program to talk to Ovation RF generator? can anybody help me out and get me started? I am stuck!!!. ... appreciate your help. thanks.
~Johnny
~ Johnny
Attachments:
Ovation - AE RF generator.pdf 1444 KBThanks... so I started with the basic serial write and read, enetered hex text strings into the serial write, including the checksum and what I read back is not always correct because for example I need to calculate the XOR in the program and not just eneter it as a hex value. I should also put the write and read into a loop because I will be writing and reading to serial port 2 dozen times.
I am working with two devices, one is the generator, the other is a controller board that has a very similar serial bus structure as the generator's AE serial bus. the controller board has stepper motor drivers that move two variable capacitors. for the generator, I need to turn the power on and off and set to different power levels. for the control/stepper motor driver board: I need to read the values from a text file(attached). the text file has 3 table, table1, column1 is the number of steps that the stepper motor will move and column2 is the nominal capacitor values for C1. same thing table2; values are number of steps versus nominal cap values for C2. I need to creat a matrix such that to move the C1 to steps listed in the table, and for every step increment in C1, I need to move the C2 motor to 20 different position (listed in the table3 that has the desired percent value of total capacitance ) position and make a measurement of the impedance of the capacitors with agilant E5061 network analyzer and write the data back into the same text file at the end where it says "IMPEDANCE_REAL in Ohm one line per C1 position" and into a excel sheet too while taking a measurement... and do the same thing all over again for C2 versus C1. I think I need to use the producer consumer design pattern eventually when I get the details worked out first.
any suggestion? .... much thanks.
~ Johnny
~ Johnny
Attachments:
Basic Serial Write and Read1.vi 24 KB
cap-table.txt 7 KB
Maybe you are looking for
-
Iphoto shows pictures on an event that are replaced by others when double clicked
I have a very strange issue going on with my iphoto. I imported about 80 pictures. Then asked iphoto to delete from camera (First time I do this). When ckecking the event i saw some pictures that were repeated and some seemed to be missing. I tho
-
Consolidator class error in java code...
Hi, I have difficult time for testing create publication programically. Test step is 1. create MOBILEADMIN.EMP2 based by SCOTT.EMP 2. Create Primary Key to MOBILEADMIN.EMP2 3. Write Test Code My test code is....as follows.. [Publication2.java] import
-
Execute a query in Jdeveloper using DB adpater
Hi All , In jdeveloper, using DB adapter i want to execute the following query , select segment1,eng_item_flag from table_name where segment1 in ('itemnumber1','itemnumber2'); In the query the operation IN got used so could you please help me to proc
-
hi, How can we combine RFC and IDOC both to generate an XML file.?? Please describe the steps... Regards.
-
Place image icon onto a 3D cube
Hi, I am currently doing a project on 3D java. I have created 3D color cube and i am planning to put movable image icon on the cube so that i can move the image icon to anywhere on the cube. The color cube can be rotated, translated and zoomable. Las