Simple Serial Port Implementation FAILURE...MSDN?

Hi everyone!
I have a serial device connected via USB (connecting into COM7). I need to be able to read and write to/from this device. I created an external C# console application for opening the connection and writing/reading. It worked for the writing but not for the
reading. So after much trial and error, I more or less outright copied the example code the MSDN documentation provides, and this still isn't working. I am not receiving anything from the device. I have tested the device using other means such as putty and
the device is writing correctly.
Has anyone else had problems? Is the library just completely useless? Does anyone know of any alternatives?
Cheers!

Hello CRASH664,
>> Has anyone else had problems? Is the library just completely useless? Does anyone know of any alternatives?
This library should be already completed since it comes from .NET 2.0. There is a similar thread which also discusses about issues about reading data from USB by using SerialPort api:
http://stackoverflow.com/questions/11217619/can-send-cant-read-net-serial-port
It shows you could subscribe to the DataReceived Event to see if it is firing at all. And there is a Community comment about setting DTR and RTS to true, if the connected device needs them it will not transmit data.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Serial Port for Palm

    Hi:
    I have a little school project and need to use a Palm device serial port. The only problem is that it seems serial port implementation is only available for MIDPv2.0 and for Palm there's just an implementation for MIDPv1.0. I wonder if anyone knows if there's a sollution to this problem or other way to get to use serial port through MIDVPv1.0.
    Thanks.
    Alex

    You can get the adaptor at just about any computer store. Its called a serial to USB adaptor. There should also include a disk or have a download of some kind for the driver of the device. Now this may or may not work due to the m100 was not designed for a USB connection. Others on this site have tried what you are doing. Here is a link after searching for serial to USB adaptor: http://forums.palm.com/palm/search?submitted=true&q=serial+to+USB+adaptor

  • COMMAPI freeing serial port

    I have a question about Java commapi and serial ports. In my application I call close on a SerialPort object and associated input/outputstreams. Later on I try to open the port again by calling open on a CommPortIdentifier object and I get a RuntimeException with message "Device busy". If I close the application and start it again, the serial port is opened without problems. My question is should I do something more when closing the port to free it?
    Code that tries to close the port:
    inStream.close(); //inputstream
    outStream.close(); //outputstream
    inStream=null;
    outStream=null;
    port.close(); //SerialPort
    port.removeEventListener();
    port=null;My platform is Sparc Solaris 10.
    Thanking you in advance,
    Anguinus

    I know this is a very old post, but google came up with it after searching for ttyUSB0 and java, so I thought I'd chip in the solution so that other people arriving here might benefit :)
    The trick is to go into javax.comm.properties and add the ttyUSB0 to the list of serial ports:
    # Implementation specific driver
    driver=com.sun.comm.LinuxDriver
    # Paths to server-side serial port devices
    serpath0 = /dev/ttyS0
    serpath1 = /dev/ttyS1
    serpath2 = /dev/ttyUSB0               # <--- added ttyUSB0
    # Paths to server-side parallel port devices
    parpath0 = /dev/parport0
    parpath1 = /dev/parport1Works fine for me

  • How can I use the output value from SIMPLE PID to write something to the serial port?

    I am working on my Senior Design Project that requires the use of incoming compressed air, propotional valves, continuous servo motors, and a serial servo motor microcontroller.  I have figured out how to send byte sequences to the microcontroller through LabVIEW using the VISA serial write function.  The motors are attached to the valves to control the flow rate.  I have created my own simple feedback system using a bunch of case structures but I realized that I am basically trying to recreate the wheel (I basically was writing my own PID VI).   I have an older version of LabVIEW (7.0 Express) and theres no way to upgrade or buy the PID toolkit, so I am stuck using the Simple PID VI.  Also, the only way the motor works is sending an array of bytes to tell it to turn on/off, direction, and speed.  Is there any way I can use the Simple PID VI in conjunction with the VISA SERIAL write function, or is there any other way I can communicate with the serial port using this pid vi?  Any information would be appreciated.

    Hi gpatel,
    you know how to communicate to serial port, but you don't know how to send a value from SimplePID to serial port???
    You know how to communicate, but then you don't know how to communicate???
    You should explain this in more detail...
    Edit:
    From you first post you know what values your motor driver is expecting. You know which values the PID.vi is providing. Now all you need is a formula to reshape the values from PID to the motor. It's up to you to make such a formula. Unless you provide any details we cannot give more precise answers...
    Message Edited by GerdW on 02-28-2010 08:35 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Simple Serial Com port

    I have an external device that I need to write and read simple ascii commands to through a serial port. For some unknown reason I can not get Labview or for that matter M&A to com to it. I can com to it through a terminal (putty) with no problems. I have tried through M&A and also several labview basic read & Write Serial example VIs. No luck. All I need to send is  $1RD  This tells the external device to send a measurement back. Its basic ascii. The device coms on 19200 baud 8 bit words no party or flow control and 1 stop bit. Anyone have any ideas?

    Bkasper wrote:
    It works fine in putty. Yes I have to press the enter key to send the $1RD. I have tried adding \r and \s to the end of the command in labview, but no luck.
    Try adding a \r\n or just a \n to the end of the line. A carriage return by itself is not a normal line termination.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Assistance in How to Communicate to Serial Port

    Hello, I am designing an Interface to communicate with RFID Device. My problem is that I cannot seem to get the data sent to loop back and be displayed back to a textbox that I have setup. The serial port pins 2 and 3 have been connected with jumper
    wire so as to allow the data to transmit and return back. I have followed the example from an online source called "Simple Serial". Yet, everything seems to work except for the data return (received). Any assistance on the matter would be greatly
    appreciated. My apologies, I neglected to mention that I am using C# 5.0 in Visual Studio 2013 Ultimate.

    Hi,
    Your issue is out of support range of VS General Question forum which mainly discusses the usage issue of Visual Studio IDE such as
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    Because your issue is about Serial Port, you can consult on ,Net Compact Framework forum like this thread:
    https://social.msdn.microsoft.com/Forums/en-US/59db36ee-88dc-436a-9222-bb0b7f9acbeb/serial-port-communication-using-cnet?forum=netfxcompact for better support.
    Thanks,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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

  • Serial Port - Linux OK, Windows No Way

    I have been trying to write to my serial port with hardware flowcontrol under windows XP all weekend. With no flow control all is well. I was about to give up on my serial port program when I decided to try my sample app under Linux Redaht 8 using the RXTX commapi. To my surprise, the code that would not work under windows worked just fine under Linux! I'm happy and confused at the same time. Here's the code snippet that processes the serial events. Does anyone have any insight into why this simple write with flow control would not work under windows XP? I have LED's connected to the serial lines and can see the CTS line doing what it's supposed to. I have administrative rights on XP. A few observations that probably mean nothing. Windows XP repors outputbuffersize=0, yet Linux returns a value. The API notes say it is advisory and may not report a value so I don't think it means anything.
    ANY help you have would be greatly appreciated.
    Thank You!
    public void serialEvent(SerialPortEvent event) {
            long timein,timeout;
              switch(event.getEventType()) {
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                        if(boolDataforWriting & event.getNewValue()){
                                  //Write data
                             timein=System.currentTimeMillis();
                             try {
    // ########## LINE THAT PRODUCES ERROR IN WINDOWS BUT NOT LINUX ###########
                                                    streamSerialOut.write(strDataForWriting.getBytes());
                             } catch (IOException e) {
                                  e.printStackTrace(); 
                             }//end catch
                             System.out.println("-->Done writing " +strDataForWriting.length()+" Bytes. Resetting str");
                                   timeout=System.currentTimeMillis();
                                   System.out.println("--->Time to write="+ (timeout-timein) + " ms");
                             //reset flags for next write operation
                             strDataForWriting="";
                             boolDataforWriting=false;
                        }//end if
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                        break;
                   case SerialPortEvent.DATA_AVAILABLE:
                        try {
                                       byte[] readBuffer = new byte[100]; //create byte array
                                      char c;
                                      int numBytes=0;
                            while (streamSerialIn.available() > 0) {
                                     numBytes = streamSerialIn.read(readBuffer);
                                   } catch (IOException e) {}
                             break;
                                    String strtemp=(new String(readBuffer)).trim();
    }//end serialevent

    I've had this very same problem and there is a solution.
    Interestiingly I found that the same code worked on Win98 but not WinXP.
    The problem seems to lie in the JavaComm implementation. I'm guessing but your probably running with the javacomm20-win32.zip that you downloaded from Sun. I've also tried using the implementation javacom that IBM provide with there download of java1.3 and it has the same problem. So you should have a look at http://www.rxtx.org I've had success running this implementation on WinXP and Linux. To save you some time compiling there is a reasonably recent binary version at this location http://www.jcontrol.org/html/en/download.html (scroll to the bottom of the page)

  • 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
    -Russel

    Hi 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

  • I have problem with delay in serial port

    I have problem with serial port. I have connected two computers by serial port and I need to create program in Labview for transfer strings using start bits and stop bits. My problem is that my program is working quite well ...when I press start bit it starts to concatenate strings and if i press stop bits it stops...this is the purpose of this program...but problem is that it working only with delay...and need that this program dont need delay, because it can only concatenating data depends on delay from start bit....I wana solved problem with delay...I dont want using delay process in my program, but allways when I try to delete this delay it stop works correct
    here is my program

    Ok this should be simple - if I understand you correctly.
    You have the VISA session initialized with read termination character enabled.  So reading the number of bytes at port is NOT the correct way to read from the port.  Set the read number of bytes to something large (say 4096) and the read will return as soon as a termination character is received (or timeout).
    You'll need to make sure the sending device is configured to send termination character on writes (you can set that with a VISA property node)  and that you are sending the correct termination character.  The default is 0x0A (newline).
    Jeff

  • 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...        

  • 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 ?

  • USB to Serial port adapter - Mac thinks  it's a modem

    I’m trying to connect my Mac’s USB port to a Sony Beta SP recorder's Serial Port using a generic USB to Serial adapter which uses the Prolific PL-2303 chip.
    I’m using the latest Prolific Universal driver, but when I plug in the USB cable I get a message that a ‘new network device has been detected’ and suggesting that I use System Preferences to set it up. But in System Preferences it seems to think the USB to Serial adapter is a modem and is looking for a phone number and other configuration data.
    Does anyone know how to get it to work as just a serial communication device to my Sony’s serial port? If I get it working I'll be connecting it to an RS232 to RS422 adapter to talk to the Sony port.
    Thanks.

    Thanks Andy.
    I'll have a go again. It was late last night when I was trying to set it up, so maybe a fresh brain will have more success. I did try to 'Cancel' the network preference window that opened, but got the impression that it would not work unless I did 'something'. Someone else told me I could cancel that message permanently within System Preferences, so I'll try that too. Yet another bit of advice I got was that I would have to install 'MacPorts' and run something called 'Minicom' to set up the serial parameters. Windows was so simple by comparison
    As a non-techie (at least in all these software and protocol issues) I'm more than a little confused.
    Regards
    Message was edited by: esmonde

  • The "VISA Configure Serial Port" VI will only run at 9600 Baud

    I have written a Serial Port monitor "RS232 RW.vi"  that works for the most part. The problem is that it will not respond to alternate port configuration settings.... For instance: the default RS232 Serial port configuration is:
    (COM1,9600 baud,8 data bits,1 Stop bit, None no parity)
    As a test, I am using a Null Modem Cable to connect From my LabView Com1 port to another PC running RealTerm Serial Port Monitor.. Using my newly designed "RS232 RW.vi"  With port settings of (COM1,9600 baud,8 data bits,1 Stop bit, None no parity),  I can send and receive data back and forth all day long no problems....
    However, if I configure the "RS232 RW.vi"  port to any other configuration, such as (COM1,2400 baud ,7 data bits,1 stop bit, Odd parity).. It will not take the expected chances and continues to operate @ 9600 baud etc.
    I then changed the "RS232 RW.vi"  default settings to (2400,7,1,Odd)
    it still refuses to deviate from (COM1, 9600,8,1,None...)
    I also went into the Win XP  Device Manager on the LabView system and manually configured Com1 to 2400,7,1,Odd  
    and still,.... the "RS232 RW.vi"  will only operate @ 9600,8,1,None
    Can anyone else test drive my VI and see if they have the same problem of not being able to see new changes in the Port configuration settings ..other than (COM1, 9600,8,1,None...).... ?
    FYI.. Unfortunately my LabView is running on Version 6.0 so you may need to up-convert the attached vi
    Solved!
    Go to Solution.
    Attachments:
    RS232 RW.vi ‏102 KB

    Instead of just appreciating the comments, you need to implement them.
    Having the VISA close inside the loop is definitely the problem.  And Crossrulz is 100% correct about the problem being that the serial port gets reset to the default baud rate after closing the port.  Here is the proof.
    Note that while you may have set the port settings manually in device manager, those settings are revised by the VISA driver.  If you look in Measurement and Automation Explorer under Devices and Interfaces >> Serial and Parallel, you'll see the default settings that the VISA driver uses.  If you change the setting there, your program will work the way you want.  But that is not the correct fix.  The correct fix is to get the VISA close out of the while loop.
    The port settings are established in this order.
    1.  By the Windows device drivers.
    2.  By the VISA driver as established in MAX.  Since you are useing VISA, these settings will automatically override #1.
    3.  By the port settings you set programmatically in your LabVIEW program.
    Attachments:
    Example_VI.png ‏18 KB

  • 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

Maybe you are looking for

  • Script AS 1.0 for AS 2.0 - Help PLZZZZ

    Please how do I convert the code down from AS 1.0 to AS 2.0?? onClipEvent (mouseDown) { if (k> 0) return; zoom = true; dir == 1? (Dir =- 1): (dir = 1); if (dir == 1) pt = {x: _root._xmouse, y: _root._ymouse}; onClipEvent (enterFrame) { if (! zoom) re

  • Can't create a folder in Macintosh

    Hi All, I have been, having  issue with creating a Folder in my "Mac 10.7.3" in Macintosh drive, this is happen sice Thursday this week, the problem I have is that every time I want to create a New Floder, Transfer folder or Delete any file in Macint

  • Fax Integration for PO Approval WF R12.1.2

    Hi All, My third party IO team has configured this workflow for Fax integration, now when a PO is approved a Fax is getting triggered with Standard PO Communication report output. But we need the custom report to be triggered in its place. I am analy

  • When you rebuild your iPhoto library does it erase all your photos

    When you rebuild your iPhoto library does it erase your photos and my iPhoto keeps crashing i was wondering if there was a fix for this?

  • Unable to view files or web pages

    Hello, Can anyone help me out? I am using OS X 10.4.11 and I cant open certain files such as .docx nor can I view certain web pages. Thank you...