Locking access to serial ports

I have two instruments on serial ports, and two independant VIs to control them. One VI may be running, or both, at any one time. The VIs may be running under LabView, or executables.
I would like some simple and elegant way of ensuring that when I run the second VI, it cannot access whichever port is being used by the first VI. I have experimented with using the VISA Lock Async.vi, which should do exactly that. However, it seems to be possible to have two VIs lock access to the same port, without generating an error. I can only assume that the "lock" is for the application (LabView), not the VIs.
I have looked at the synchronisation functions for a solution, but I can't see any reasonable way of using them. Semaphores are ok if you want to control access to a single port, but not the undefined list of ports that may be available on any given machine.
I could use a global array variable containing a list of ports in use. Not very elegant though...

CDancer a écrit:
Thanks, guys, but I don't think you have understood my problem. Read the first sentence - 2 completely independant VIs, and 2 or more ports...
I have written a program today using the globals option, which works very well. There should be a better way though.
Chris
ViLabWorks a écrit:
It isn't exactly clear to me why this is about one port. How much does one serial port cost versus programming time? Or even if it is about 4 serial ports the same applies. For me there is no question, doing something perhaps difficult versus spending next to nothing to solve the problem.
Well...
Sometimes you need to access the same equipement from different places in your application, or from different applications...
Usually I simply set/read a global "busy" boolean.
One problem I would like to adress is the automatic detection of specific serial hardware. How is it possible to find the port on which some equipment has been connected ? Of course, a solution would be to try to connect to this equipment by sending a command and waiting for the proper answer. However, before doing that, you need to detect the available ports (VISA Find Ressource), then scan each port after setting the proper baud rate, byte length, parity, etc..., then close the port to make it available to another application. Unfortunately, within LabVIEW, this procedure may interfere with other vis already connected to other serial equipments, with impredictable results.
Apart the solution proposed in my first post, I don't know a way of deciding if a port is already in use. May be I missed something ?
Chilly Charly    (aka CC)
         E-List Master - Kudos glutton - Press the yellow button on the left...        

Similar Messages

  • How to access the serial port in Java?

    How can I initialise and access the serial port for writing and reading data from it? Are there any code examples available?

    I tried that and I tried compiling and executing one of its examples, the one below:
    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    public class SimpleWrite {
    static Enumeration portList;
    static CommPortIdentifier portId;
    static String messageString = "Hello, world!\n";
    static SerialPort serialPort;
    static OutputStream outputStream;
    public static void main(String[] args) {
    portList = CommPortIdentifier.getPortIdentifiers();
    while (portList.hasMoreElements()) {
    portId = (CommPortIdentifier) portList.nextElement();
    if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
    if (portId.getName().equals("COM1")) {
    //if (portId.getName().equals("/dev/term/a")) {
    try {
    serialPort = (SerialPort)
    portId.open("SimpleWriteApp", 2000);
    } catch (PortInUseException e) {}
    try {
    outputStream = serialPort.getOutputStream();
    } catch (IOException e) {}
    try {
    serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e) {}
    try {
    outputStream.write(messageString.getBytes());
    } catch (IOException e) {}
    But when I execute this I get the error:
    Exception in thread "main" java.lang.NoClassDefFoundError: SimpleWrite
    What is wrong with this example??

  • [SOLVED] How to set non-root access to serial ports?

    I have this device which is listed as
    /dev/ttyUSB0
    I need to
    sudo chown sms /dev/ttyUSB0
    every time I reboot. Normally I would think to add myself to some group but "tty" group is not doing the trick... proof:
    [sms@sms-linux ~]$ groups sms
    tty wheel sms
    [sms@sms-linux ~]$ MinOZW
    Starting MinOZW with OpenZWave Version 1.0.758
    2014-03-15 06:32:07.921 Cannot find a path to the configuration files at ../../../config/, Using /usr/local/etc/openzwave/ instead...
    2014-03-15 06:32:07.928 mgr, Added driver for controller /dev/ttyUSB0
    2014-03-15 06:32:07.929 Opening controller /dev/ttyUSB0
    2014-03-15 06:32:07.931 Trying to open serial port /dev/ttyUSB0 (attempt 1)
    2014-03-15 06:32:07.933 ERROR: Cannot open serial port /dev/ttyUSB0. Error code 13
    2014-03-15 06:32:07.935 ERROR: Failed to open serial port /dev/ttyUSB0
    2014-03-15 06:32:07.936 WARNING: Failed to init the controller (attempt 0)
    ^C
    [sms@sms-linux ~]$ sudo MinOZW
    [sudo] password for root:
    Starting MinOZW with OpenZWave Version 1.0.758
    2014-03-15 06:32:23.776 Cannot find a path to the configuration files at ../../../config/, Using /usr/local/etc/openzwave/ instead...
    2014-03-15 06:32:23.782 mgr, Added driver for controller /dev/ttyUSB0
    2014-03-15 06:32:23.784 Opening controller /dev/ttyUSB0
    2014-03-15 06:32:23.786 Trying to open serial port /dev/ttyUSB0 (attempt 1)
    2014-03-15 06:32:23.794 Serial port /dev/ttyUSB0 opened (attempt 1)
    Edit: yes, it was after logout and even reboot.
    Last edited by smsware (2014-03-15 15:07:15)

    Hi,
    I also have a similar problem. I added myself to uucp group, but I still cannot access the serial port.
    [manjaro@mycomp work]$ sudo gpasswd -a manjaro uucp
    [sudo] password for manjaro:
    Adding user manjaro to group uucp
    [manjaro@mycomp work]$ groups manjaro
    lp wheel uucp network video audio storage users
    [manjaro@mycomp work]$ ls -l /dev/ttyUSB0
    crw-rw---- 1 root uucp 188, 0 23.06.2014 21:32 /dev/ttyUSB0
    [manjaro@mycomp work]$ lpc21isp firmware.hex /dev/ttyUSB0 19200 11059
    lpc21isp version 1.97
    File firmware.hex:
    loaded...
    Start Address = 0x00004F9C
    converted to binary format...
    image size : 30304
    Image size : 30304
    Can't open COM-Port /dev/ttyUSB0 ! (Error: 13d (0xD))
    But when I try as root, it works:
    [manjaro@mycomp work]$ sudo lpc21isp firmware.hex /dev/ttyUSB0 19200 11059
    [sudo] password for manjaro:
    lpc21isp version 1.97
    File firmware.hex:
    loaded...
    Start Address = 0x00004F9C
    converted to binary format...
    image size : 30304
    Image size : 30304
    Synchronizing (ESC to abort)..... OK
    Read bootcode version: 13
    Download Finished... taking 27 seconds
    Now launching the brand new code
    Do you have any idea what I am doing wrong?
    Last edited by manjaro (2014-06-23 19:57:40)

  • How to access the serial port on sdk 3.1.3 ?

    Hi all,
    I know that accessing serial port is not possible on firmware 2.x for non jailbroken iPhones.
    But what about firmware 3.0?
    Apple has focused firmware 3.0 on accessories, through bluetooth or through serial port. So, accessing serial port should be possible.
    But I can't find any documentation / sample code for that.
    Would you please help me?
    Regards,
    Alx
    PS: I tried to read the port /dev/cu.iap and get this message:
    Error opening serial port /dev/cu.iap - Permission denied(13).
    Looks bad.

    Yes I am enregistred in the Mad For iPod program?
    And I try to communique with my accessorie
    So the Code
    +*// SerialPortsModuleAppDelegate.m*+
    +*// SerialPortsModule*+
    +*// Created by BPO iMac on 08/02/10.*+
    +*// Copyright _MyCompanyName_ 2010. All rights reserved.*+
    +*#import "SerialPortsModuleAppDelegate.h"*+
    +*#import <fcntl.h>*+
    +*@implementation SerialPortsModuleAppDelegate*+
    +*@synthesize window;*+
    +*- (void)applicationDidFinishLaunching:(UIApplication *)application {*+
    +*// Override point for customization after application launch*+
    +*[window makeKeyAndVisible];*+
    +* portSerie = [SerialManager alloc];*+
    +* [portSerie init];*+
    +* int nb_port;*+
    +* nb_port = [portSerie findRS232Ports];*+
    +* NSString path_port;+
    +* path_port = [NSString alloc];*+
    +* int num_port;*+
    +* if(nb_port!=0)*+
    +* {*+
    +* num_port=0;*+
    +* path_port=[portSerie pathAtIndex:num_port];*+
    +* int resultat= [portSerie openInput:path_port baudrate:9600 bits:8 parity:0 stopbits:1 flags:O_RDONLY];*+
    +* if(resultat==-1)*+
    +* {*+
    +* NSLog(@"Communication Error");*+
    +* }*+
    +* resultat= [portSerie openOutput:path_port baudrate:9600 bits:8 parity:0 stopbits:1];*+
    +* if(resultat==-1)*+
    +* {*+
    +* NSLog(@"Communication Error");*+
    +* }*+
    +* }*+
    +* [path_port release];*+
    +* *+
    +*- (void)dealloc {*+
    +*[window release];*+
    +*[super dealloc];*+
    @end
    +*// SerialPortsModuleAppDelegate.h*+
    +*// SerialPortsModule*+
    +*// Created by BPO iMac on 08/02/10.*+
    +*// Copyright _MyCompanyName_ 2010. All rights reserved.*+
    +*#import <UIKit/UIKit.h>*+
    +*#import "SerialManager.h"*+
    +*@interface SerialPortsModuleAppDelegate : NSObject <UIApplicationDelegate> {*+
    +*UIWindow window;+
    +* SerialManager portSerie;+
    +*@property (nonatomic, retain) IBOutlet UIWindow window;+
    @end
    +*// SerialManager.m*+
    +*// K3 Tools*+
    +*// Created by Kok Chen on 4/28/09.*+
    +*// Copyright 2009 Kok Chen, W7AY. All rights reserved.*+
    +*#import "SerialManager.h"*+
    +*#include <unistd.h>*+
    +*#include <termios.h>*+
    +*#include <sys/ioctl.h>*+
    +*#include <IOKit/IOKitLib.h>*+
    +*#include <IOKit/serial/IOSerialKeys.h>*+
    +*#import <fcntl.h>*+
    +*#import <UIKit/UIKit.h>*+
    +*@implementation SerialManager*+
    +*- (id)init*+
    +* self = [ super init ] ;*+
    +* if ( self ) {*+
    +* termiosBits = -1 ;*+
    +* inputfd = outputfd = -1 ;*+
    +* useTermiosThread = NO ;*+
    +* needsNotification = NO ;*+
    +* termioLock = [ [ NSLock alloc ] init ] ;*+
    +* }*+
    +* return self ;*+
    +*static int findPorts( CFStringRef *stream, CFStringRef *path, int maxDevice, CFStringRef type )*+
    +*kernreturnt kernResult ;*+
    +*machportt masterPort ;*+
    +* ioiteratort serialPortIterator ;*+
    +* ioobjectt modemService ;*+
    +*CFMutableDictionaryRef classesToMatch ;*+
    +* CFStringRef cfString ;*+
    +* int count ;*+
    +*kernResult = IOMasterPort( MACHPORTNULL, &masterPort ) ;*+
    +*if ( kernResult != KERN_SUCCESS ) return 0 ;*+
    +* *+
    +*classesToMatch = IOServiceMatching( kIOSerialBSDServiceValue ) ;*+
    +*if ( classesToMatch == NULL ) return 0 ;*+
    +* *+
    +* // get iterator for serial ports (including modems)*+
    +* CFDictionarySetValue( classesToMatch, CFSTR(kIOSerialBSDTypeKey), type ) ;*+
    +*kernResult = IOServiceGetMatchingServices( masterPort, classesToMatch, &serialPortIterator ) ;*+
    +* // walk through the iterator*+
    +* count = 0 ;*+
    +* while ( ( modemService = IOIteratorNext( serialPortIterator ) ) ) {*+
    +* if ( count >= maxDevice ) break ;*+
    +*cfString = IORegistryEntryCreateCFProperty( modemService, CFSTR(kIOTTYDeviceKey), kCFAllocatorDefault, 0 ) ;*+
    +*if ( cfString ) {*+
    +* stream[count] = cfString ;*+
    +* cfString = IORegistryEntryCreateCFProperty( modemService, CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0 ) ;*+
    +* if ( cfString ) {*+
    +* path[count] = cfString ;*+
    +* count++ ;*+
    +* }*+
    +* }*+
    +*IOObjectRelease( modemService ) ;*+
    +* IOObjectRelease( serialPortIterator ) ;*+
    +* return count ;*+
    +*// return number of ports*+
    +*- (int)findPorts:(CFStringRef)type*+
    +* CFStringRef cstream[64], cpath[64] ;*+
    +* int i ;*+
    +* *+
    +* numberOfPorts = findPorts( cstream, cpath, 64, type ) ;*+
    +* for ( i = 0; i < numberOfPorts; i++ ) {*+
    +* stream = [ [ NSString stringWithString:(NSString*)cstream ] retain ] ;*+
    +* CFRelease( cstream ) ;*+
    +* path = [ [ NSString stringWithString:(NSString*)cpath ] retain ] ;*+
    +* CFRelease( cpath ) ;*+
    +* }*+
    +* return numberOfPorts ;*+
    +*- (int)findPorts*+
    +* return [ self findPorts:CFSTR( kIOSerialBSDAllTypes ) ] ;*+
    +*- (int)findModems*+
    +* return [ self findPorts:CFSTR( kIOSerialBSDModemType ) ] ;*+
    +*- (int)findRS232Ports*+
    +* return [ self findPorts:CFSTR( kIOSerialBSDRS232Type ) ] ;*+
    +*- (NSString)streamAtIndex:(int)n+
    +* if ( n < 0 || n >= numberOfPorts ) return nil ;*+
    +* return stream[n] ;*+
    +*- (NSString)pathAtIndex:(int)n+
    +* if ( n < 0 || n >= numberOfPorts ) return nil ;*+
    +* return path[n] ;*+
    +*// common function to open port and set up serial port parameters*+
    +*static int openPort( NSString *path, int speed, int bits, int parity, int stops, int openFlags, Boolean input )*+
    +* int fd, cflag ;*+
    +* struct termios termattr ;*+
    +* *+
    +* fd = open( [ path cStringUsingEncoding:NSASCIIStringEncoding], openFlags ) ;*+
    +* if ( fd < 0 ) return -1 ;*+
    +* *+
    +* // build other flags*+
    +* cflag = 0 ;*+
    +* cflag |= ( bits == 7 ) ? CS7 : CS8 ; // bits*+
    +* if ( parity != 0 ) {*+
    +* cflag |= PARENB ; // parity*+
    +* if ( parity == 1 ) cflag |= PARODD ;*+
    +* }*+
    +* if ( stops > 1 ) cflag |= CSTOPB ;*+
    +* *+
    +* // merge flags into termios attributes*+
    +* tcgetattr( fd, &termattr ) ;*+
    +* termattr.c_cflag &= ~( CSIZE | PARENB | PARODD | CSTOPB ) ; // clear all bits and merge in our selection*+
    +* termattr.c_cflag |= cflag ;*+
    +* *+
    +* // set speed, split speed not support on Mac OS X?*+
    +* cfsetispeed( &termattr, speed ) ;*+
    +* cfsetospeed( &termattr, speed ) ;*+
    +* // set termios*+
    +* tcsetattr( fd, TCSANOW, &termattr ) ;*+
    +* return fd ;*+
    +*- (int)openInput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags*+
    +* return ( inputfd = openPort( pathname, speed, bits, parity, stops, openFlags, YES ) ) ;*+
    +*- (int)openInput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops*+
    +* return ( inputfd = openPort( pathname, speed, bits, parity, stops, ( O_RDONLY | O_NOCTTY | O_NDELAY ), YES ) ) ;*+
    +*- (int)openOutput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags*+
    +* return ( outputfd = openPort( pathname, speed, bits, parity, stops, openFlags, NO ) ) ;*+
    +*- (int)openOutput:(NSString*)pathname baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops*+
    +* return ( outputfd = openPort( pathname, speed, bits, parity, stops, ( O_WRONLY | O_NOCTTY | O_NDELAY ), NO ) ) ;*+
    +*- (void)closeInput*+
    +* if ( inputfd > 0 ) close( inputfd ) ;*+
    +*- (void)closeOutput*+
    +* if ( outputfd > 0 ) close( outputfd ) ;*+
    +*- (int)inputFileDescriptor*+
    +* return inputfd ;*+
    +*- (int)outputFileDescriptor*+
    +* return outputfd ;*+
    +*- (int)getTermios*+
    +* int bits ;*+
    +* *+
    +* if ( inputfd > 0 ) {*+
    +* [ termioLock lock ] ;*+
    +* ioctl( inputfd, TIOCMGET, &bits ) ;*+
    +* [ termioLock unlock ] ;*+
    +* return bits ;*+
    +* }*+
    +* return 0 ;*+
    +*- (void)setRTS:(Boolean)state*+
    +* int bits ;*+
    +* if ( inputfd > 0 ) {*+
    +* [ termioLock lock ] ;*+
    +* ioctl( inputfd, TIOCMGET, &bits ) ;*+
    +* if ( state ) bits |= TIOCM_RTS ; else bits &= ~( TIOCM_RTS ) ;*+
    +* ioctl( inputfd, TIOCMSET, &bits ) ;*+
    +* [ termioLock unlock ] ;*+
    +* }*+
    +*- (void)setDTR:(Boolean)state*+
    +* int bits ;*+
    +* if ( inputfd > 0 ) {*+
    +* [ termioLock lock ] ;*+
    +* ioctl( inputfd, TIOCMGET, &bits ) ;*+
    +* if ( state ) bits |= TIOCM_DTR ; else bits &= ~( TIOCM_DTR ) ;*+
    +* ioctl( inputfd, TIOCMSET, &bits ) ;*+
    +* [ termioLock unlock ] ;*+
    +* }*+
    +*// IO Notifications*+
    +*// prototype for delegate*+
    +*- (void)port:(NSString*)name added:(Boolean)added*+
    +* if ( delegate && [ delegate respondsToSelector:@selector(port:added:) ] ) [ delegate port:name added:added ] ;*+
    +*// this is called from deviceAdded() and deviceRemoved() callbacks*+
    +*- (void)portsChanged:(Boolean)added iterator:(ioiteratort)iterator*+
    +* ioobjectt modemService ;*+
    +* CFStringRef cfString ;*+
    +* while ( ( modemService = IOIteratorNext( iterator ) ) > 0 ) {*+
    +* cfString = IORegistryEntryCreateCFProperty( modemService, CFSTR( kIOTTYDeviceKey ), kCFAllocatorDefault, 0 ) ;*+
    +* if ( cfString ) {*+
    +* [ self port:(NSString*)cfString added:added ] ;*+
    +* CFRelease( cfString ) ;*+
    +* }*+
    +* IOObjectRelease( modemService ) ;*+
    +* }*+
    +*// callback notification when device added*+
    +*static void deviceAdded(void *refcon, ioiteratort iterator )*+
    +* ioobjectt modemService ;*+
    +* *+
    +* if ( refcon ) [ (SerialManager*)refcon portsChanged:YES iterator:iterator ] ;*+
    +* else {*+
    +* while ( modemService = IOIteratorNext( iterator ) ) IOObjectRelease( modemService ) ;*+
    +* }*+
    +*static void deviceRemoved(void *refcon, ioiteratort iterator )*+
    +* ioobjectt modemService ;*+
    +* *+
    +* if ( refcon ) [ (SerialManager*)refcon portsChanged:NO iterator:iterator ] ;*+
    +* else {*+
    +* while ( modemService = IOIteratorNext( iterator ) ) IOObjectRelease( modemService ) ;*+
    +* }*+
    +*- (void)startNotification*+
    +* CFMutableDictionaryRef matchingDict ;*+
    +* *+
    +* notifyPort = IONotificationPortCreate( kIOMasterPortDefault ) ;*+
    +* CFRunLoopAddSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource( notifyPort ), kCFRunLoopDefaultMode ) ;*+
    +* matchingDict = IOServiceMatching( kIOSerialBSDServiceValue ) ;*+
    +* CFRetain( matchingDict ) ;*+
    +* CFDictionarySetValue( matchingDict, CFSTR(kIOSerialBSDTypeKey), CFSTR( kIOSerialBSDAllTypes ) ) ;*+
    +* *+
    +* IOServiceAddMatchingNotification( notifyPort, kIOFirstMatchNotification, matchingDict, deviceAdded, self, &addIterator ) ;*+
    +* deviceAdded( nil, addIterator ) ; // set up addIterator*+
    +* IOServiceAddMatchingNotification( notifyPort, kIOTerminatedNotification, matchingDict, deviceRemoved, self, &removeIterator ) ;*+
    +* deviceRemoved( nil, removeIterator ) ; // set up removeIterator*+
    +*- (void)stopNotification*+
    +* if ( addIterator ) {*+
    +* IOObjectRelease( addIterator ) ;*+
    +* addIterator = 0 ;*+
    +* }*+
    +* if ( removeIterator ) {*+
    +* IOObjectRelease( removeIterator ) ;*+
    +* removeIterator = 0 ;*+
    +* }*+
    +* if ( notifyPort ) {*+
    +* CFRunLoopRemoveSource( CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource( notifyPort ), kCFRunLoopDefaultMode ) ;*+
    +* IONotificationPortDestroy( notifyPort ) ;*+
    +* notifyPort = nil ;*+
    +* }*+
    +*// prototype for delegate or subclass*+
    +*- (void)controlFlagsChanged:(int)termbits*+
    +* if ( delegate && [ delegate respondsToSelector:@selector(controlFlagsChanged:) ] ) [ delegate controlFlagsChanged:termbits ] ;*+
    +*- (void)termiosThread*+
    +* NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ] ;*+
    +* int termbits ;*+
    +* while ( 1 ) {*+
    +* if ( useTermiosThread == NO ) break ;*+
    +* if ( inputfd > 0 ) {*+
    +* if ( [ termioLock tryLock ] ) {*+
    +* ioctl( inputfd, TIOCMGET, &termbits ) ;*+
    +* if ( termiosBits != termbits ) [ self controlFlagsChanged:termbits ] ;*+
    +* termiosBits = termbits ;*+
    +* [ termioLock unlock ] ;*+
    +* }*+
    +* [ NSThread sleepUntilDate:[ NSDate dateWithTimeIntervalSinceNow:0.25 ] ] ;*+
    +* }*+
    +* else {*+
    +* [ NSThread sleepUntilDate:[ NSDate dateWithTimeIntervalSinceNow:1.0 ] ] ;*+
    +* }*+
    +* }*+
    +* [ pool release ] ;*+
    +*// If delegate is set, setDelegate also starts a termiosThread if delegate responds to -controlFlagsChanged:*+
    +*- (void)setDelegate:(id)object*+
    +* delegate = object ;*+
    +* if ( delegate == nil ) {*+
    +* useTermiosThread = NO ;*+
    +* if ( needsNotification ) {*+
    +* needsNotification = NO ;*+
    +* [ self stopNotification ] ;*+
    +* }*+
    +* }*+
    +* else {*+
    +* if ( [ delegate respondsToSelector:@selector(controlFlagsChanged:) ] ) {*+
    +* useTermiosThread = YES ;*+
    +* [ NSThread detachNewThreadSelector:@selector(termiosThread) toTarget:self withObject:nil ] ;*+
    +* } *+
    +* if ( [ delegate respondsToSelector:@selector(port:added:) ] ) {*+
    +* needsNotification = YES ;*+
    +* [ self startNotification ] ;*+
    +* }*+
    +* }*+
    +*- (id)delegate*+
    +* return delegate ;*+
    @end
    +*// SerialManager.h*+
    +*// K3 Tools*+
    +*// Created by Kok Chen on 4/28/09.*+
    +*// Copyright 2009 Kok Chen, W7AY. All rights reserved.*+
    +*//#import <Cocoa/Cocoa.h>*+
    +*#import <Foundation/Foundation.h>*+
    +*#import <UIKit/UIKit.h>*+
    +*#import <CoreData/CoreData.h>*+
    +*//#import <IOKit/IOKitLib.h>*+
    +*//#import <IOKitLib.h>*+
    +*#include <IOKit/IOKitLib.h>*+
    +*typedef int FileDescriptor ;*+
    +*@interface SerialManager : NSObject {*+
    +* NSLock *termioLock ;*+
    +* FileDescriptor outputfd ;*+
    +* FileDescriptor inputfd ;*+
    +* id delegate ;*+
    +* // serial ports in system*+
    +* NSString *stream[64] ;*+
    +* NSString *path[64] ;*+
    +* int numberOfPorts ;*+
    +* *+
    +* // termios*+
    +* int termiosBits ;*+
    +* Boolean useTermiosThread ;*+
    +* *+
    +* // IO notifications*+
    +* IONotificationPortRef notifyPort ;*+
    +* ioiteratort addIterator, removeIterator ;*+
    +* Boolean needsNotification ;*+
    +*- (void)setDelegate:(id)sender ;*+
    +*- (int)findPorts ;*+
    +*- (int)findModems ;*+
    +*- (int)findRS232Ports ;*+
    +*- (NSString*)streamAtIndex:(int)n ;*+
    +*- (NSString*)pathAtIndex:(int)n ;*+
    +*- (FileDescriptor)openInput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops ;*+
    +*- (FileDescriptor)openInput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags ;*+
    +*- (FileDescriptor)openOutput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops ;*+
    +*- (FileDescriptor)openOutput:(NSString*)path baudrate:(int)speed bits:(int)bits parity:(int)parity stopbits:(int)stops flags:(int)openFlags ;*+
    +*- (void)closeInput ;*+
    +*- (void)closeOutput ;*+
    +*- (FileDescriptor)inputFileDescriptor ;*+
    +*- (FileDescriptor)outputFileDescriptor ;*+
    +*- (int)getTermios ;*+
    +*- (void)setRTS:(Boolean)state ;*+
    +*- (void)setDTR:(Boolean)state ;*+
    +*- (void)setDelegate:(id)object ;*+
    +*- (id)delegate ;*+
    +*// delegates*+
    +*- (void)port:(NSString*)name added:(Boolean)added ;*+
    +*- (void)controlFlagsChanged:(int)termbits ;*+
    @end
    Could you help me ?

  • Raw access to serial port /dev/ttya

    I need to control the characteristics of the serial port /dev/ttya on a Sun-Blade-100 running SOLARIS 8 from Java (JRE 6).
    The purpose is to set the baud rate, parity bits, etc.
    On my PC (development infrastructure, WinXP) I am using the javax.comm libraries and everything is fine. However, when copying the application to the SUN, no available ports are shown and the app terminates.
    I suspect that I am missing some low-level stuff that accesses the devices ?!
    Any ideas would be welcome!
    Udo

    (b) sounds like the best solution to me.
    Google search result that seems reasonably close to what you need.
    http://www.linuxquestions.org/questions … ce-644237/

  • Problems with access to serial port using reentrant code

    Hi,
    I have a VI that send commands and receive answers from an instrument using
    de serial port.
    This VI runs perfectly when used alone.
    However I'm trying run two instances of that VI simultaneously using
    reentrant code and I'm facing some problems.
    Sometimes everything is OK but sometimes, in the process of writing to
    serial port the following error happen:
    Error code 36.
    Invalid refnum device.
    What is this?
    Does someone know how to prevent this?
    Thanks in advance for any help.

    "Paro, Paula [CMPS:2721:EXCH]" wrote:
    >
    > Hi,
    >
    > I have a VI that send commands and receive answers from an instrument using
    > de serial port.
    > This VI runs perfectly when used alone.
    > However I'm trying run two instances of that VI simultaneously using
    > reentrant code and I'm facing some problems.
    > Sometimes everything is OK but sometimes, in the process of writing to
    > serial port the following error happen:
    > Error code 36.
    > Invalid refnum device.
    >
    > What is this?
    > Does someone know how to prevent this?
    >
    > Thanks in advance for any help.
    You can't use reentrant vi's vith serial vi calls without supervising of
    driver.
    Use VISA instead and you have to control the VISA session opening and
    closing. Another word is that the only one serial port sess
    ion should be
    opened at a time.
    Reentrant vi's for serial port without checking serial port session is a
    mistake of program algorithm. Change it in any convenient way.
    Sergey Krasnishov
    Automated Control Systems
    National Instruments Alliance Member
    Moscow, Russia
    [email protected]
    http://acs.levsha.ru

  • Access to serial port ttyS0

    Hello,
    I'm trying to use a self-built mgetty+sendfax package (the one in AUR doesn't compile here) to access my modem on /dev/ttyS0 (to send faxes to DSL / VoIP). The mgetty+sendfax program "fax-helper" normally runs as user "fax" and tries to access ttyS0 as group "uucp". That worked some months ago, at that time /dev/ttyS0 had the following access rights:
    crw-rw---- 1 root uucp 4, 64  1. Jan 21:56 /dev/ttyS0
    But now the right to access ttyS0 is more restricive:
    crw------- 1 root root 4, 64  1. Jan 21:56 /dev/ttyS0
    The group changed from "uucp" to "root" only - and the fax-helper application of mgetty+sendfax can't access the port any more. Of course, faxing works when I manually change the group to "uucp" before sending the fax. After reboot, the access rights for /dev/ttyS0 then are again restrictive root.root.
    What is the optimal solution for this issue?
    a) Using hylafax instead of mgtetty+sendfax. I haven't tried hylafax yet, so I don't know whether hylafax solved the problem.
    b) Setting up an udev rule to change the access rights for /dev/ttyS0. Will that work?
    c) Use a fax service in the internet (that's not free of charge while for DSL / VoIP I have a flatrate).
    d) Try to modify mgetty+sendfax to run the fax-helper application as root?
    Your help will be appreciated.

    (b) sounds like the best solution to me.
    Google search result that seems reasonably close to what you need.
    http://www.linuxquestions.org/questions … ce-644237/

  • Can air for html/ajax accessing serial port or usb?

    I just have made use of Adobe AIR .I want to use printer with
    air . Do air have some poperties to accessing serial port or usb?
    I look up that on the Adobe AIR documents.I only found
    'Adobe® AIR™ provides the eans to check for changes to
    the network connectivity of the computer on which an AIR
    application is installed'.
    Do you have some demo with Adobe AIR accessing serial port or
    usb ?
    Or has another poperties to do that!
    thank you!!

    There is no API for accessing the serial port. USB devices
    can only be accessed through the file system (and only if they are
    storage devices).

  • How to access serial port using servlet

    I want to communicate with a microcontroller connected to the serial port of my computer.
    *I am using the following:
    Windows 98 operating system
    Tomcat web server 4.1
    *The directory structure is as given:
    Tomcat 4.1/webapps/myjsp/web-inf/classes/remoteservlets.
    I have placed my jsp files in my jsp folder and classfiles in remote servlets folder.
    **my java program has compiled correctly.**
    ** my simple java application which accesses the serial port works fine.***
    *when I start tomcat I am able to access the sevlet as the servlet responds with the button name i have pressed.
    **** I have also tried the following
    Copied file comm.jar in <JAVA_HOME>\jre\lib\ext
    Copied file javax.comm.properties in <JAVA_HOME>\jre\lib
    Copied file win32com.dll in <JAVA_HOME>\lib and also in c:\windows\system32 and c:\windows\system
    ***************which helped me do away with errors.
    still I don't get any output. I dont get any errors either.
    PLEASE HELP. URGENT. i am at my wits end.
    Thank you.

    Servlet is the one which runs in the server side...if u want to comunicate with the serial port of the server in which ur servlet is running can be done but making use of Communication api available....
    U can download the Api from http://java.sun.com/products/javacomm/index.jsp
    There are three levels of classes in the Java communications API:
    High-level classes like CommPortIdentifier and CommPort manage access and ownership of communication ports.
    Low-level classes like SerialPort and ParallelPort provide an interface to physical communications ports. The current release of the Java communications API enables access to serial (RS-232) and parallel (IEEE 1284) ports.
    Driver-level classes provide an interface between the low-level classes and the underlying operating system. Driver-level classes are part of the implementation but not the Java communications API. They should not be used by application programmers.
    regards
    shanu

  • Pse help. K7T66Pro2 cannot access serial ports in DOS window

    My K7T266Pro2 won't access serial ports in a DOS window under Windows 98SE.
    Windows programs can access the ports but no DOS programs - including my modem program, banking program, Tapcis Compuserve program and MDMDR a serial port diagnostic program.
    I have tried both setting the ports in BIOS to AUTO
    and forcing the standard values for com1 and 2
    and I have verified that the serial ports are set for:
    com1 irq 4 i/o 3f8
    com2 irq 3 i/o 2f8
    I know my way around serial ports.
    Every other motherboard I have used under Windows 98SE has had no problems accessing the serial ports
    under DOS.
    I asked my dealer to try another K7T motherboard.  He loaded Windows 98SE and could not access the serial
    port in a DOS window either.
    Is this something funny about K7T boards?
    Do others have this problem?
    This is a quite urgent problem.  Please help.
    Larry Alkoff

    Larry,
    You posted in the nVidia/AMD/SiS Forum instead of the Via Forum. I have moved you to the correct forum.
    Good Luck,
    Richard

  • Accessing serial port on Arm platform

    I need to read and write on the serial ports of an ARM platform with a Java application, running a cross-compiled JVM.
    I considered both solutions java COMMAPI and JNI, but the problem is the same: I haven't library to support them: libLinuxSerialParallel.so, to support COMMAPI, or libnativelib.so, to implement native methods for JNI.
    How can I have this library for my ARM architecture? Is it possible to cross-compile sources for it?
    Thanks in advance.
    regards.

    Hello,
    I have a igep boar with arm core.
    I am trying to access to serial port through java.
    I am using rxtx (gnu.io) http://rxtx.qbang.org.
    I dowloaded the api for arm architecture (http://rxtx.qbang.org/ToyBox/2.1-7-build1/Linux/glibc-2.3.5/), but there is a problem with dependencies with glib.
    This is the error when i try to call from java:
    java.lang.UnsatisfiedLinkError: /home/jdoe/equinox-SDK-3.5.2/plugins/configuration/org.eclipse.osgi/bundles/2/1/.cp/librxtxSerial.so: /lib/vfp/libpthread.so.0: version `GLIBC_2.0' not found (required by /home/jdoe/equinox-SDK-3.5.2/plugins/configuration/org.eclipse.osgi/bundles/2/1/.cp/librxtxSerial.so) thrown while loading gnu.io.RXTXCommDriver
    I tested the librxtxSerial.so:
    jdoe@ubuntu:~$ ldd librxtxSerial.so
    ./librxtxSerial.so: /lib/vfp/libpthread.so.0: version `GLIBC_2.0' not found (required by ./librxtxSerial.so)
    ./librxtxSerial.so: /lib/vfp/libc.so.6: version `GLIBC_2.1.3' not found (required by ./librxtxSerial.so)
    ./librxtxSerial.so: /lib/vfp/libc.so.6: version `GLIBC_2.1' not found (required by ./librxtxSerial.so)
    ./librxtxSerial.so: /lib/vfp/libc.so.6: version `GLIBC_2.0' not found (required by ./librxtxSerial.so)
    libpthread.so.0 => /lib/vfp/libpthread.so.0 (0x40022000)
    libc.so.6 => /lib/vfp/libc.so.6 (0x40041000)
    /lib/ld-linux.so.3 (0x2a000000)
    And this is my glic version:
    jdoe@ubuntu:~$ ls -al /lib/libc*
    -rwxr-xr-x 1 root root 1201672 2009-04-09 18:02 /lib/libc-2.9.so
    lrwxrwxrwx 1 root root 14 2010-07-01 16:52 /lib/libcap.so.1 -> libcap.so.1.10
    -rw-r--r-- 1 root root 13984 2008-11-14 02:47 /lib/libcap.so.1.10
    lrwxrwxrwx 1 root root 14 2010-06-16 17:21 /lib/libcap.so.2 -> libcap.so.2.11
    -rw-r--r-- 1 root root 13800 2008-11-17 06:14 /lib/libcap.so.2.11
    -rw-r--r-- 1 root root 181816 2009-04-09 18:02 /lib/libcidn-2.9.so
    lrwxrwxrwx 1 root root 14 2010-06-16 17:21 /lib/libcidn.so.1 -> libcidn-2.9.so
    lrwxrwxrwx 1 root root 17 2010-06-16 17:21 /lib/libcom_err.so.2 -> libcom_err.so.2.1
    -rw-r--r-- 1 root root 9648 2009-02-12 16:55 /lib/libcom_err.so.2.1
    -rw-r--r-- 1 root root 38400 2009-04-09 18:02 /lib/libcrypt-2.9.so
    -rw-r--r-- 1 root root 1210776 2009-04-04 03:06 /lib/libcrypto.so.0.9.8
    lrwxrwxrwx 1 root root 15 2010-06-16 17:21 /lib/libcrypt.so.1 -> libcrypt-2.9.so
    lrwxrwxrwx 1 root root 11 2010-06-16 17:21 /lib/libc.so.6 -> libc-2.9.so
    What should I do?

  • Help - K7T266Pro2 won't access serial ports in DOS window

    My K7T266Pro2 won't access serial ports in a DOS window under Windows 98SE.
    Windows programs can access the ports but no DOS programs - including my modem program, banking program, Tapcis Compuserve program and MDMDR a serial port diagnostic program.
    I have tried both setting the ports in BIOS to AUTO
    and forcing the standard values for com1 and 2
    and I have verified that the serial ports are set for:
    com1 irq 4 i/o 3f8
    com2 irq 3 i/o 2f8
    I know my way around serial ports.
    Every other motherboard I have used under Windows 98SE has had no problems accessing the serial ports
    under DOS.
    I asked my dealer to try another K7T motherboard.  He loaded Windows 98SE and could not access the serial
    port in a DOS window either.
    Is this something funny about K7T boards?
    Do others have this problem?
    This is a quite urgent problem.  Please help.
    Larry Alkoff

    Larry,
    You posted in the nVidia/AMD/SiS Forum instead of the Via Forum. I have moved you to the correct forum.
    Good Luck,
    Richard

  • Serial Ports using HyperV in Ubuntu guest OS

    I need to run a terminal session (term) from within the guest OS, Ubuntu 12.04.3 LTS to a serial port on the Windows 8.1P host. In my case a USB to serial adapter that Windows has mapped to COM5.
    I don't really know where to start.  In HyperV, under Settings, I see a Com1 and Com2 under hardware. The two options are None or Named pipe.  Not all that clear what to do here.
    Presumably this is what will be visible to Ubuntu as  /dev/ttyXX   ??
    Can anyone point the way to map a serial port into Ubuntu?   Or a suitable workaround?
    Thanks.

    "How can a VM be so cut off from the hardware like that?"
    Well, for the most part, it's been a long time since I have even seen a machine with a serial port on it.  It is so uncommon that one generally needs to buy an add-on card or do something like USB to serial.  That trend has been going on for a
    long time - that's why network based serial devices have tended to the solution for this.  This is nothing new.  Even Microsoft's Virtual Server, the precursor to Hyper-V (which was released five years ago) did not have access to serial ports.
    Since you are asking in the Hyper-V forum, the answer is you can't get to a physical serial port on your host.
    .:|:.:|:. tim

  • J2ME in Pocket PC - sockets - serial port

    Hi Guys,
    I am writing a J2ME application for a Pocket PC using Windows Mobile 2003
    I have chosen the J9 VM to run my J2ME applications on the PPC.
    My application will use tcp/ip sockets communication to connect to a server. Do you know if there are any issues of using this part of J2ME on a Pocket PC?? ( I have tested the same application on Java enabled mobile phone and it is fine)
    I also want to access the serial port from my J2ME application (read/write data). Do you know if it is possible to do it on a Pocket PC through the normal way?? (using the javax.microedition.io package??)

    evelknievel you said that implemmented bluetooth
    connection like a serial link, where can i find some
    documentation to do that?i am sorry, that i cannot offer you a link to a tutorial, because i just tried it out by myself using an iPAQ h5550 with windows CE 4.2 (i think this is equivlent to PocketPC 2003, or 2003 SE) which is able to create such connections. the bluetooth-driver of each side of your "serial bluetooth link" has to implement the so called "serial port profile". maybe you should google for it...
    i found some information on this:
    "To open the connection using the:
    * PocketPC
    o Most Bluetooth drivers for PocketPC provide the mapping between Bluetooth serial ports and virtual COM (inbound/outbound) ports. For example WIDCOMM Bluetooth driver (BTW-CE 1.4) that comes with hp iPAQ h5550 by default assigns COM port 5 as the inbound Bluetooth serial port and COM port 8 as the outbound Bluetooth serial port. These COM ports are configurable from the driver's Bluetooth manager."
    i found it here:
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/15987c8cb752ead786256dc20070b433?OpenDocument
    hopefully this information is useful to you or anybody else :)
    best regards
    evelknievel

  • Serial Port not accessible until I run MAX

    Hi!
    On my machine I can access all Serial ports perfectly. I put a Vias Resource in my VI and get a drop down menu with all my serial ports. But on other machines (Runtime v7 and VISA runtime installed) I don´t get the names (e.g. com1 com2) but only
    ASRL1:****
    ASRL2:****
    ASRL10:****
    I know that ASRL1 is COM1 but when I select it it dowsn´t work.
    If I now install MAX on the machine and run it once without changing the configuration my ports work.
    Can anybody tell me how to use the ports without using MAX??
    regards
    hmann

    Hi hmann,
    When you run MAX it is configuring your VISA alias list behinf the scenes. See "JB" answer to this question to find out how to do this without using MAX. It basicly requires editing an INI file.
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000238D0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0
    I hope this help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • JRE will crash on NT4/Win2K if not logged in as admin !

    I have this problem with JDK/JRE 1.2.2 as well as with JDK/JRE 1.3. I already posted this about a year ago but didn't get any replies. Although I have only the full JDK installed I think it is definitely a JRE-related problem: I can only run Java app

  • How to add Comma and Tabs in Calc Script Header

    Hi, I need to add in the begging of the report script the following lines: PNL OPENB 1/31/2020 12 R,N,Y 5     6     7     2     3     1     I     C     8     9     A     D     V     V     V     V     V     V     V     V     V     V     V     V The la

  • How to use external Microphone in Logic pro 8?

    I am trying to use a condenser mic with interface (blue iclcle USB) and all I am getting is the internal mic. Does anyone know how to change this? Thanks L

  • Uploaded iOS 4.2 for my iPad and now can't use it

    Please help. I uploaded iOS 4.2 for my iPad and now I can't update, restore, or get my iPad to show up on iTunes. When I click restore it gets to "Preparing iPad for restore", then states it can't restore due to error 1604. I have followed the troubl

  • WHAT...Can't perform digital download. Do I have to downgrade to IE 7 or 8 because I have 11.

    I just purchased the add-on for Dishonored via digital download. Now I cannot download because it says I do not have the correct equipment.  I HAVE Windows 7, BUT I run IE 11, which is the latest.  It shows I need 7 or 8?  Really?  Do I have to downg