Serial port definitions/handling questions

Xserve (brand spanking new), 10.6.2
1- Setting speed for the tty.serial port
I edited, as documnented, the /etc/ttys file to use "serial.9600" instead of "serial.57600" which unfortunatly is now default for the one serial port of the Xserve. Then I "kill -HUP 1" to get launchd to refresh its definition. No difference.
In the end, out of desperation after many trials without success, I edit /etc/getttytab and change sp#57600 to sp#9600 in the serial.57600 definition and this finally worked.
This sort of indicates to me that launchd no longer uses /etc/ttys but some other hidden file where the serial.57600 is assigned to getty and tty.serial.
Anyone know where the serial ports are now defined ?
Also, once the system is up, is there a way to release the port from the login process so that I could make an outbound connection using cu/screen ?

Thanks for the responses.
I suspected it was in a PLIST, but I am not yet used to the Snow Leopard finder to get to "unix" directory and hadn't gotted a list of files in that directory and figured it was empty and that the launchd plists were elsewhere. Argh ! That is what lack of sleep does
I take it that in that plist, the "SessionCreate" refers to the "on" or "off" that one uses in ttys ?
Also, if I am to get an 8 port USB gizmo, would I be adding them to the comp.apple.xserve.serial-ports plist ? In which case, I take it that the launchctl control is an all or nothing, unable to control individual ports ? Should I then create individual plists for each port so I can control them individually ?
BTW, while launchctl unload did remove the getty process assigned to tty.serial, the port is still marked as "Line in use" and "cu" unable to use it.

Similar Messages

  • Dev question - is it possible to read the iPhone serial port?

    Hi,
    apologies if this is not the right place to ask this question. If so, please let me know the correct place.
    I am new to iPhone sw development and would like to know if its possible for a non-jailbroken 3G iphone to read/write data to the serial port (dock connector). Am trying to find out before I invest in a special device I'd like to connect.
    thanks much,
    'mark

    http://developer.apple.com/iphone/program/accessories/
    For additional information, refer to the documentation for the iPhone 3.0 SDK or ask in the iPhone developer forums.

  • Hola!!!Yesterday, I asked a question about serial port comunication, because I wanted to find a function in Labview similar to "ProcessSystem Events" in Labwindows!!

    My problem is that I have written a comand through the serial port, and I doesn´t receive the answer. If I execute the programm step by step, I don´t have any problem but if the program runs i don´t get the answer!!!It is not a problem of the bytes that I write and receive, i have used the function "Visa Bytes at Serial Port"!!I have used th function "wait" but it doesn´t work!!!!i have used a Flat sequence but it hasn´t solved the problem!!so, i don´t know what i can do!!!
    I attach the "different versions" that i did, maybe someone find a solution!!
    Dennis, I have the problem, when
    I read the last time in the program, I don´t receive the answer!thank you!!!
    Gracinda
    Attachments:
    salida_analogica.vi ‏67 KB
    config_rango.vi ‏41 KB
    salida_ana_v1.vi ‏69 KB

    Dear Mads;
    Thank you for your answer.
    I don´t have a termination character but I know the number of bytes that I have to receive. I tried checking the number of bytes that I received, using "Bytes at Port", but it gets a value and it isn´t refreshed, it has a value so my program stop in the while structure that I have added. I attach the vi. I don´t know how to do that. I am starting with Labview, and it is a little difficult for me!!
    In the first change that I did, I added the function "Bytes at Port" inside the While loops, but it doesn´t work either !!!
    Thank you!
    Attachments:
    entrada_analogica.vi ‏94 KB

  • Java Serial Port Question !

    Hello,
    I am writing characters such as "open\r", "close\r" to the serial port of a PC from the Java program. This PC is connected to robot controller through the serial port.
    Suppose, I am writing open\r to the serial port. After writing open\r, the controller immediately echos "open" back to the serial port, which my Java program can read & print. Then, approximately after 1 second, when the robot actually executes the open (Open Gripper) command, the controller sends "Done.>" this response. I want to monitor & read this response "Done.>" because I want to check controller's response ("Done.>") before sending next command.
    1. Is it MUST to listen & read data at port at the time the data comes? Does the data gets lost if we don't read the data at the time it comes? For example, if data comes at 10000 millisecs, then is it MUST to start reading at 10000 or 10001? Would that data get lost if we start reading after say 3 seconds i.e. at 13000?
    2. If some data ("Done") comes at the serial port from controller and the Java program does not read that and if suppose more data (".>")comes at the serial port after 1/2 second, then does the previous data("Done") gets erased?
    3. My problem is --> the java program that I have written, can sometimes read & print controller's response --> "Done.>" and other times it does not find "Done.>"....That means the data --> "Done.>" is getting lost somewhere or Java program is not able to read it..The controller always sends "Done.>" when it excecutes "open" command.
    Thank You !
    Mayur
    Below is the code I am using...
    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    public class WriteReadEdit implements SerialPortEventListener {
    CommPortIdentifier portId;
    Enumeration portList;
    OutputStream outputStream;
    InputStream inputStream;
    SerialPort serialPort;
    public static void main(String[] args) {
              String command1 = "open\r";
              String command2 = "close\r";                    
              boolean EndCharacterQMark = false;
              WriteReadEdit readObject = new WriteReadEdit();
                   readObject.Write(command1);
                   try {
                        EndCharacterQMark = readObject.waitUntilDataComes();
                        System.out.println("EndCharacterQMark is: " + EndCharacterQMark);
                   }     catch (IOException e) {}
                        if(EndCharacterQMark) {
                             EndCharacterQMark = false;
                             readObject.Write(command2);
                             try {
                                  EndCharacterQMark = readObject.waitUntilDataComes();
                                  System.out.println("EndCharacterQMark is: " + EndCharacterQMark);
                             }     catch (IOException e) {}
                        readObject.closePort();
    synchronized boolean waitUntilDataComes() throws IOException {
         String total="";
         boolean EndCharQMark = false;
         StringBuffer inputBuffer = new StringBuffer();
         int newData = 0;
         while(true) {
                        if(!dataAvailable()) {
                             try {                              
                                  wait();                              
                             }catch (InterruptedException e) {}
                   try {
                        while (newData != -1) {                         
                             newData = inputStream.read();
                             inputBuffer.append((char)newData);
                   }          catch (IOException ex) {
                             System.err.println(ex);
                        String dataAtPort = inputBuffer.toString();
                        for(int i = 0; i < dataAtPort.length(); i++) {                         
                                  if(dataAtPort.indexOf("?")>1 || dataAtPort.indexOf(">")>1 ) {
                                  EndCharQMark = true;
                                  return EndCharQMark;
    boolean dataAvailable() throws IOException {          
         return inputStream.available() > 0;
              void Write(String commandToSend) {
              String command = commandToSend;
              try {
                        outputStream.write(command.getBytes());                              
                        System.out.println("\nSuccessfully Written: " + command);
              } catch (IOException e) {System.out.println("IO Exception Occured: " + e);
    void closePort() {
         serialPort.close();
         System.out.println("Port closed successfully.");
    // Constructor()
    public WriteReadEdit() {
              portList = CommPortIdentifier.getPortIdentifiers();
              while (portList.hasMoreElements()) {
              portId = (CommPortIdentifier) portList.nextElement();
                        if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
              if (portId.getName().equals("COM1")) {
              try {
              serialPort = (SerialPort) portId.open("writereadobjectApp", 2000);
                   System.out.println("Opened the port for writing: " + portId.getName());
              } catch (PortInUseException e) {
              try {
                   serialPort.setSerialPortParams(9600,
              SerialPort.DATABITS_8,
              SerialPort.STOPBITS_1,
              SerialPort.PARITY_NONE);
              } catch (UnsupportedCommOperationException e) {
                                            System.out.println("UnsupportedCommOperationException, Could not set the port: " + e);
                                       try {                                        
                                            outputStream = serialPort.getOutputStream();
                                            inputStream = serialPort.getInputStream();
                                       } catch (IOException e) {
                                       try {
                                            serialPort.addEventListener(this);
                                       } catch (TooManyListenersException e) {}
                                       serialPort.notifyOnDataAvailable(true);
    synchronized public void serialEvent(SerialPortEvent event) {
         switch(event.getEventType()) {
         case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
         case SerialPortEvent.DATA_AVAILABLE:
         notifyAll();          
         break;

    1. Usually there are buffers in the serial port controller. Apart from that, as long as the port is open, any data recieved will be added at the end of the InputStream of the comport so nothing will be lost.
    2. Nope, see above. But there might just be some kind of limit there.
    3. Download portmon http://www.sysinternals.com/ntw2k/freeware/portmon.shtml or any other prog that is able to monitor what's happening on you're serial port. This allows you to see if the response is really send by the robot.
    You're code seem to me to be more complex then it needs to be. Check out javax.comm.CommPort.enableRecieveTimeout(int). Setting a timeout will cause the the read function to return when the timeout is passed or data is recieved. A timeout of of say 4sec whould make sure that when a reply is send, it is recieved and it's stops reading when it gets no reply.
    In that case you could do with a sendMsg function wich dus not return until the correct response is recieved, or the timeout passed.
    You migth consider putting all the communicatoin with the com port in a different Thread so the rest of the program runs on when that thread is listening to the port...
    Hope this helps you a bit...

  • Handle Event for Characters At Serial Port in an eventstructure

    I want to write an event driven application for serial communcation without polling for characters at serial port, instead I want to have an event case in the event structure for this event. Is this possible and how can i do it?

    You should be able to execute the example that I posted with an event structure in parallel. I modified the last example so that on thread is waiting for the serial event and then another thread is executing an event structure that just increments a counter. You should be able to increment the counter any time you want and the serial event will complete as soon as a message is read independent of one another.
    Unfortunately, I don't know how to (and I am not sure you can) setup an event structure to work with VISA or DAQ events. If you put your VISA Wait on Event inside of your event structure it will hold and prohibit any other events from executing until it is done. However, if any event fires it will block the other
    events until it completes. If you uncheck the box under the your event properties you can prevent the front panel from locking. This will at least queue up the events.
    I hope this helps out. Attached are some examples.
    -Josh
    Attachments:
    visaRead.vi ‏42 KB
    visaRead2.vi ‏49 KB
    visaRead3.vi ‏49 KB

  • Question of commapi - BlackBox could not find serial port.

    Hi,
    I have installed jdk1.5.0_04 and commapi2.0_win32 at following directory
    c:\Java\netbeans-4.1
    c:\Java\jdk1.5.0_04
    c:\Java\commapi
    C:\Program Files\Java\jre1.5.0_04
    Then I do exactly what installation instruction ask me to do
    Copy win32com.dll to c:\Java\jdk1.5.0_04\bin
    Copy comm.jar to c:\Java\jdk1.5.0_04\lib
    Copy javax.comm.properties to c:\Java\jdk1.5.0_04\lib
    However, when I run BlackBox,BlackBox still gives me a message that
    says "No serial ports found!"
    Can any one help me out, thanks in advance ?
    Daniel

    Many forum posts about installation to java 1.4. Also see:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=453195
    and
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=444673
    I had success on winXP when I installed to the JRE below Program Files/java, no success when installed to c:\j2sdk etc etc.
    The directions for setting the classpath seem bogus; I did not need to specify a class path. Simply went to the commapi/samples/BlackBox folder, then typed java BlackBox. It found a couple of ports. I think this means that (despite the post in the forum to the contrary) that the comm API can deal with the NT hardware abstraction layer (HAL) just fine.
    I'm very new to this, hope this helps.
    chris...

  • How to get data from serial port to GUI textArea

    From Serial Port.....
    Messages from base (always 5 bytes):
    0xAA, 0, 0, 0, 0xBB - IDLE Mode
    0xAA, 0, 0x80, 0x80, 0xBB - Question Mode
    messages from terminal (always 6 bytes):
    0xAA, a, b, c, chksum, 0xBB
    where chksum = a+b+c;
    a = address (0-250)
    the 2 MSB's of b represenet the answer:
    0 0 - A
    0 1 - B
    1 0 - C
    1 1 - D
    the 6LSB's of b and 8bits of c is the time for answer, in milliseconds.
    (0-16384 milliseconds)
    I have VB Code for that but I want the same thing in Java ...
    Can any one help me?
    Here's VB Code..
    VERSION 5.00
    Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
    Begin VB.Form Form1
       BorderStyle     =   1  'Fixed Single
       Caption         =   "Aakar GUI"
       ClientHeight    =   4665
       ClientLeft      =   60
       ClientTop       =   375
       ClientWidth     =   6105
       LinkTopic       =   "Form1"
       MaxButton       =   0   'False
       MinButton       =   0   'False
       ScaleHeight     =   311
       ScaleMode       =   3  'Pixel
       ScaleWidth      =   407
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton cmdPort
          Caption         =   "Open Port"
          Height          =   375
          Left            =   120
          TabIndex        =   4
          Top             =   600
          Width           =   1455
       End
       Begin VB.ComboBox cmbPort
          Height          =   315
          ItemData        =   "Form1.frx":0000
          Left            =   120
          List            =   "Form1.frx":0016
          Style           =   2  'Dropdown List
          TabIndex        =   3
          Top             =   120
          Width           =   2895
       End
       Begin VB.CommandButton cmdEnd
          Caption         =   "End"
          Height          =   495
          Left            =   1560
          TabIndex        =   2
          Top             =   1320
          Width           =   1215
       End
       Begin VB.CommandButton cmdStart
          Caption         =   "Start"
          Height          =   495
          Left            =   120
          TabIndex        =   1
          Top             =   1320
          Width           =   1215
       End
       Begin VB.TextBox txtMessage
          Height          =   2040
          Left            =   119
          MultiLine       =   -1  'True
          ScrollBars      =   3  'Both
          TabIndex        =   0
          Top             =   2475
          Width           =   5848
       End
       Begin VB.Timer tmrRead
          Enabled         =   0   'False
          Interval        =   1
          Left            =   2040
          Top             =   600
       End
       Begin MSCommLib.MSComm MSComm1
          Left            =   3120
          Top             =   360
          _ExtentX        =   1164
          _ExtentY        =   1164
          _Version        =   393216
          DTREnable       =   0   'False
          ParityReplace   =   45
          SThreshold      =   1
       End
       Begin VB.Label Label5
          Caption         =   "Result Data:"
          Height          =   375
          Left            =   120
          TabIndex        =   5
          Top             =   2115
          Width           =   1320
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    Dim PortIsOpen As Boolean
    Dim Answers(4) As String
    Dim RejectKeystroke As Boolean
    Private Sub cmbPort_Change()
    Debug.Print cmbPort.ListIndex
    End Sub
    Private Sub cmbPort_Validate(Cancel As Boolean)
    'Cancel = True
    End Sub
    Private Sub cmdEnd_Click()
    MSComm1.Output = "e"
    txtMessage.Text = ""
    End Sub
    Private Sub cmdPort_Click()
    On Error GoTo ErrorHandler
    If cmbPort.ListIndex < 0 Then Exit Sub
    If PortIsOpen Then
        cmbPort.Enabled = True
        MSComm1.PortOpen = False
        PortIsOpen = False
        cmdPort.Caption = "Open Port"
        cmdStart.Enabled = False
        cmdEnd.Enabled = False
    Else
        MSComm1.CommPort = cmbPort.ListIndex + 1
        cmbPort.Enabled = False
        MSComm1.PortOpen = True
        PortIsOpen = True
        cmdPort.Caption = "Close Port"
        cmdStart.Enabled = True
        cmdEnd.Enabled = True
    End If
    Exit Sub
    ErrorHandler:
    Debug.Print Err.Number
    Debug.Print Err.Description
    MsgBox Err.Description, vbExclamation Or vbOKOnly, "Error opening port"
    cmbPort.Enabled = True
    PortIsOpen = False
    cmdPort.Caption = "Open Port"
    cmdStart.Enabled = False
    cmdEnd.Enabled = False
    End Sub
    Private Sub cmdStart_Click()
    MSComm1.Output = "s"
    txtMessage.Text = ""
    End Sub
    Private Sub Form_Initialize()
    Dim tmp As Variant
    tmp = InitCommonControls
    End Sub
    Private Sub Form_Load()
    Answers(0) = "A"
    Answers(1) = "B"
    Answers(2) = "C"
    Answers(3) = "D"
    'MSComm1.Settings = "9600,n,8,1"
    ''MSComm1.Settings = "115200,n,8,1"
    'MSComm1.PortOpen = True
    On Error GoTo ErrorHandler1
    MSComm1.CommPort = 1                    ' comm port 1
    MSComm1.RThreshold = 1                  ' use 'on comm' event processing
    MSComm1.Settings = "9600,n,8,1"         ' baud, parity, data bits, stop bits
    MSComm1.SThreshold = 1                  ' allows us to track Tx LED
    MSComm1.InputMode = comInputModeText    'comInputModeBinary  ' binary mode, you can also use
                                            ' comInputModeText for text only use
    PortIsOpen = False
    cmbPort.ListIndex = 0
    ' open the port
    MSComm1.PortOpen = True
    cmbPort.Enabled = False
    PortIsOpen = True
    cmdPort.Caption = "Close Port"
    cmdStart.Enabled = True
    cmdEnd.Enabled = True
    Exit Sub
    ErrorHandler1:
    Debug.Print Err.Description
    PortIsOpen = False
    cmbPort.Enabled = True
    cmdPort.Caption = "Open Port"
    cmdStart.Enabled = False
    cmdEnd.Enabled = False
    End Sub
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If MSComm1.PortOpen Then MSComm1.PortOpen = False
    End Sub
    Private Sub lblOption_Click()
    End Sub
    Private Sub MSComm1_OnComm()
    ' Synopsis:     Handle incoming characters, 'On Comm' Event
    ' Description:  By setting MSComm1.RThreshold = 1, this event will fire for
    '               each character that arrives in the comm controls input buffer.
    '               Set MSComm1.RThreshold = 0 if you want to poll the control
    '               yourself, either via a TImer or within program execution loop.
    '               In most cases, OnComm Event processing shown here is the prefered
    '               method of processing incoming characters.
        Dim i As Long
        Dim sBuff    As String           ' buffer for holding incoming characters
        Const MTC       As String = vbCrLf  ' message terminator characters (ususally vbCrLf)
        Const LenMTC    As Long = 2         ' number of terminator characters, must match MTC
        Dim iPtr        As Long             ' pointer to terminatior character
        ' OnComm fires for multiple Events
        ' so get the Event ID & process
        Select Case MSComm1.CommEvent
            ' Received RThreshold # of chars, in our case 1.
            Case comEvReceive
                ' read all of the characters from the input buffer
                ' StrConv() is required when using MSComm in binary mode,
                ' if you set MSComm1.InputMode = comInputModeText, it's not required
                'sBuff = sBuff & StrConv(MSComm1.Input, vbUnicode)
                'If Len(txtMessage.Text) > 4096 Then txtMessage.Text = ""
                sBuff = MSComm1.Input
                Dim ch As String
                Dim PacketStart As Boolean
                Dim PacketLength As Integer
                Dim Packet() As String
                PacketStart = False
                PacketLength = 0
                While (Len(sBuff) > 0)
                    ch = Left(sBuff, 1)
                    If (ch = Chr(&HAA)) Then PacketStart = True
                    If (ch = Chr(&HBB)) Then PacketStart = False
                    If (ch <> Chr(&HAA) And ch <> Chr(&HBB)) Then
                        PacketLength = PacketLength + 1
                        ReDim Preserve Packet(PacketLength)
                        Packet(PacketLength) = ch
                    End If
                    'txtMessage.Text = txtMessage.Text + Format(Hex(Asc(ch)), " @@")
                    sBuff = Right(sBuff, Len(sBuff) - 1)
                Wend
                If (PacketLength = 3) Then
                    Debug.Print "Command packet recieved"
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(1)))
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(2)))
                End If
                If (PacketLength = 4) Then
                    Debug.Print "Response packet recieved"
                    txtMessage.Text = txtMessage.Text + "Address =" + Str(Asc(Packet(1))) + _
                        " Answer = " + Answers((Asc(Packet(2)) And &HC0) / 64) + _
                        " Time =" + Str((Asc(Packet(2)) And &H3F) * 256 + (Asc(Packet(3)))) + "mS" + vbCrLf
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(1)))
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Option =" + Str((Asc(Packet(2)) And &HC0) / 64)
                    'txtMessage.Text = txtMessage.Text + vbCrLf + "Time =" + Str((Asc(Packet(2)) And &H3F) * 256 + (Asc(Packet(3))))
                End If
                If (PacketLength <> 4 And PacketLength <> 3) Then Debug.Print "Unknown packet of length" + Str(PacketLength) + " recieved"
                txtMessage.Text = txtMessage.Text + vbCrLf
            ' An EOF charater was found in the input stream
            Case comEvEOF
                DoEvents
            ' There are SThreshold number of characters in the transmit  buffer.
            Case comEvSend
                DoEvents
            ' A Break was received.
            Case comEventBreak
                DoEvents
            ' Framing Error
            Case comEventFrame
                DoEvents
            ' Data Lost.
            Case comEventOverrun
                DoEvents
            ' Receive buffer overflow.
            Case comEventRxOver
                DoEvents
            ' Parity Error.
            Case comEventRxParity
                DoEvents
            ' Transmit buffer full.
            Case comEventTxFull
            ' Unexpected error retrieving DCB]
            Case comEventDCB
                DoEvents
        End Select
    End Sub
    Private Sub tmrRead_Timer()
    'MSComm1.Output = vbCrLf + vbCrLf
    'MSComm1.Output = Chr(128)
    End Sub
    Private Sub txtMessage_KeyDown(KeyCode As Integer, Shift As Integer)
    If Shift = 2 Or Shift = 4 Then RejectKeystroke = False Else RejectKeystroke = True
    End Sub
    Private Sub txtMessage_KeyPress(KeyAscii As Integer)
    If RejectKeystroke Then
        KeyAscii = 0
    End If
    End SubThanks in advance..

    I want to replicate the entire VB program as Java Program.
    This has to be included in my project which i am doing in java.

  • Listen to serial port open by another applicatio​n

    I have a test setup where another application is communicating with a device over a serial port and I want my Labview gui to be able to listen to the communication. Since two applications cannot have the same serial port open I can't just open the port and do a visa read. Is there any way to do an unreserved open and only listen to communication on the serial port or do I physically have to break out the receive line in hardware and add a second serial port in order to do this?

    A better solution would be to have your reader post a message to a queue with the data. You can have a separate task that handles the UI updates. Depending on the type and amount of data you may not need to post all of the data.
    The answer to your specific question though is no, you cannot have two readers on the same connection.
    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

  • Serial port: Input/output signal errantly combined

    I am currently in the process of using LabView to replace another user interface for a scientific instrument.
    LabView is connected to this instrument through a serial port.  The instrument streams 25 bytes of binary data every second to the computer.  I can read the binary string (VISA Read) and save contiuously to disk using a while loop.  In addition, there are a few instructions I can send to the instrument that will do various functions (start logging, turn LEDs on/off, etc).  I can successfully send these instructions to the instrument using the previous interface, and in a stand-alone vi using VISA Write, but when I place the VISA Write function into the larger interface vi, signals go haywire.  Specifically, there are two separate LEDs that I can toggle with two different commands, but when in the larger interface vi, both commands toggle the same LED.  Also, it appears that the singal I send to the instrument (a single ASCII character) immediately bounces back to the computer into the 25 bytes of streaming binary data.  In other words, after I press the LED "on" key, one column of my streaming data changes when it is not supposed to (ex: after Binary to ASCII conversion, it changes from a single digit to a twenty digit value).
    Initially, I thought the problem was the sequence of VISA Read/Write.  In the current configuration, I read all data, then allow for Write commands.  Both the VISA functions are within the same While loop to continuously monitor the data.  Is it possible the Write signal output is not leaving the while loop and being read as input?  What would make the instrument read two different commands as the same one?  My goal is to run an interface that displays the streaming data as ASCII, and allows for a few different toggle options while the interface is running - is there are more efficient/elegant way than a while loop?
    ~Going Bananas
    Solved!
    Go to Solution.

    New replies now in gray.
    CodeMunkee wrote:
    1.  If you keep giving me good advice like this, I'll be tempted to change the background to Baltimore prison purple.
    I'll ignore this statement.
    2.  The buffer now lives outside the loop.  I understand clearly.  Part of the problem might be my instrument - when I cycle power the 19 digit number that was 'echoed' disappears.  Forget about that display stuff, it works properly - I accidentally removed the time delay when editing the vi.   But you do bring up an interesting point...
    Without the delay, the loop ran much faster.  If the bytes weren't at the port, the read statement would have returned nothing when it read zero bytes, thus blanking out the indicator rather quickly.
    Yes, Hexadecimal display shows 04 to indicate the end of the 25-byte data sample.
    Doing a bytes at port read is not always a good idea.  If not all the bytes had arrived yet when you ask for the read, you won't get all the data.  The remaining data being sent in that stream from the instrument will show up at the front of the buffer on the next read command. 
    While this isn't a common occurence, it does happen.  How can I prevent this from ever happening?
    Since you know each commands ends with a hex 04 (ASCII character for EOT), you could enable the termination character when you configure the serial port.  Set the termination character to be 4.  Then when you execute the VISA read, read a large number of bytes such as 25 or more.  The read will terminate at either the timeout, the requested number of bytes, or when the termination character is read.  With this setup, you could eliminate the wait statement and also not request the number of bytes as the port.  The VISA read will control the pacing of the loop.  Any extra bytes after the termination character are part of the next frame of data and will wait around until the next time you read the VISA port.
      3.  Implementing your ideas for the latch button works better.  I am still encountering issues with these commands however.  Attached is the new vi.  There are two commands I want to send, 't' turns on the LED light (they blink for 30 sec then time out), and the latch works perfectly for that, 'p' turns on the magnetometer light (an additional 'p' is required to turn it off), but I cannot get the command sent to the mag while the loop is running.  It turns on either at the beginning of the vi, or at the end of the vi (after Finish button is pressed).  This leads me to think the command 'p' is stuck inside the loop.  I tried adding another film strip (see attached vi) for the toggles to force the issue, but it didn't work. Additionally, the 'p' command effectively works as a 't' command, and the LED lights begin to blink when I press the 'p' button.  This isn't supposed to happen, and leads me to believe the 'p' command does in fact exit the loop but in the wrong manner.
    The "film strip" is another frame of a flat sequence structure.  It enforces the order of execution.  The next frame can't execute until everything in the prior frame has completed.  It isn't necessary in your case because the Error and VISA wires determine the order of execution with respect to the other VISA statements.  But it shouldn't hurt.
    There is no reason the "p" case structure should behave any differently than the "t" case structure.  Although you should wire the error wire through in the False case of the "p" structure like you did for the "t" structure.  There is no "exiting of the loop" in either case.  The loop runs until the stop button is pressed.  I would check the manual to see that t and p commands do what you think they should do.  Do they need a termination character of their own when they are sent?  Should they be upper case letters rather than lower case?  You can run NI Spy on your serial port and see the operations occurring with it and see the data coming in and what data is going out.  I would be suspicious that the device is not handling the command properly.
    Any ideas?  I think I've tried to put the toggle buttons outside the loop before, but then could only toggle once before the loop took over.  Ideally, these toggles would be available at any time while the data is streaming, so therefore inside the loop?
    The toggle buttons need to be within the loop so that they can be read on every iteration of the loop.  Outside the loop, as you discovered, they are only read once at the very beginning before the loop is started.
    4.  Thank you for the suggestion about the Selection Mode for the Open/Create File option.  It is annoying to create a file first.  I made the change, but I still get error messages when I use a file that does not yet exist.  LabView takes me to the first Open/Create/Replace vi when the error occurs.  Is there something else I must do?
    On the open file VI, there is an input that is Open as default when unwired.  Create a constant there and change to Replace or Create.
    Remember, if you have any questions about the way LabVIEW is handling something with serial ports, close the port within LabVIEW.  Open Hyperterminal and try the commands from there.
    Message Edited by Ravens Fan on 01-13-2009 03:55 PM

  • NI Serial Port / Eurotherm Temperature Controller

    NI Serial Port / Eurotherm Temperature Controller
    I am using a N.I. AT 232/4 board with four additional N.I. serial ports. First of all, after installing Windows NT (before I was using Windows 98) the NI Serial Port Diagnostics Program was not able to detect any of the ports even though the ports are correctly installed within Windows. When I was still using Windows 98 the NI Serial Port Diagnostics Program was able to detect all the four ports. Is it necessary that the diagnostics program detects the ports in order to use them with Lab View? I have also two regular Serial ports, which have never been detected by the diagnostics program, but I should still be able to use them with Lab view as well? D
    oes the NI Serial Port Diagnostics Program not function with Windows NT? Do you have an update version for Windows NT?
    I�m trying to control a Eurotherm 2416 and 903 Temperature Controller with two serial ports. Unfortunately, Eurotherm does not give support anymore about Lab View drivers for their Controllers, since they have developed their own Automation Program (iTools) now. I still want to control the Eurotherm Controller with Lab View via the serial port. Do you still have the driver VI�s for the 2416 and 903? It would be nice if you could send me the Eurotherm divers also along with some documentation.
    There is already a question posted about Eurotherm Controller (Eurotherm Temperature Controller not Functioning with NI Serial Board). It is probably a similar problem unfortunately the solution did not bring the right success. Therefore, I would like to ask you to specify the so-called 4-Wire mode.
    Thank You very much for Your help!
    Sincerely,
    Benjamin Thoma

    NI-Serial 1.45 does not install correctly on Windows NT Server 4.0 Terminal Server Edition. The driver (serial.sys), configuration utility (niports.cpl), and inf file (niserial.inf) are installed incorrectly to the user profiles directory.
    A workaround is to copy the files to the right folders which is detailed shortly.
    Definition: "%windows%" refers to the operating system folder. Note: The default operating system folder for this version of Windows is "Wtsrv".
    serial.sys - %windows%\system32\drivers
    niports.cpl - %windows%\system32
    niserial.inf - %windows%\inf
    Note: "niserial.inf" does not need to be copied unless an AT card is being used.
    The above files can either be obtained from the installation CD in the WinNT folder or from the hard-disk locations that they were
    incorrectly installed to which are detailed shortly. Note: Leaving the incorrectly installed files where they are will not harm the system. Definition: "%userid%" refers to the ID that was used when logging in to Windows.
    serial.sys - %windows%\Profiles\%userid%\Windows\system32\drivers
    niports.cpl - %windows%\Profiles\%userid%\Windows\system32
    niserial.inf - %windows%\Profiles\%userid%\Windows\inf
    For the newly copied driver to take effect the system must be rebooted.
    As for the instrument drivers, you can search our instrument driver site to try to find them. Go to "other driver resources" at the link below.
    http://zone.ni.com/idnet/
    For more information on the 4-wire mode, see chapter 6 of the "Serial Hardware and Software for Windows User Manual". I have included a link to the manual.
    http://digital.ni.com/manuals.nsf/caba5d53e9b015a186256793004eebb7/d1260d4fb98e3f228625699f005968d1?OpenDocument
    Kim L.
    Applications Engineer
    National Instruments

  • Serial port hang/freeze

    On rare occasions my application freezes.  What I believe is happening is that the VISA Read or VISA Write vi never returns.  (The program is an executable, so I can’t go to the diagram to be sure.  I just released a new version that will help me isolate it further, but it takes time to propagate new software to users.)  I do have the timeout set to 500ms, and I know this works because it timeouts when I have no hardware attached.
    When the freeze happens, I have to go to the Task Manager to kill my application; however, it never actually quits.  It goes away on the Applications tab, but won’t leave the Processes tab.  Selecting End Process on the Processes tab won't make it go away either.  I can get it to go away, however, by unplugging the USB cable.  I then plug the cable back in, relaunch my application, and all is OK.  (A restart works, too.)  I am using the FTDI 2232 USB to dual serial port chip (set up for RS485) in my system.
    My first question is whether anyone has seen this before or has a suggestion to get this work.
    My second question is how do I figure out what is actually hanging?  My LabVIEW 8.5.1 executable calls a VISA 4.41 driver.  The VISA driver calls a Windows COM port driver.  The Windows COM port driver calls the FTDI driver (Version 2.4.6).  The FTDI driver calls the USB driver.  We are running Windows XP with all updates installed.
    I have about 50 of these systems running continuously.  I see about one freeze like this once every few days on a random system.  I am not able to reproduce it on demand.  Any debug solution will have to be deployable to all 50 systems; otherwise, it is possible that I won't see the bug for weeks, if ever.
    Thanks in advance for the help.
    Matt K.

    Just dug out the email from FTDI support....
    Blue 
    Hello,
    If it is an application problem then what could happen is you ask to read 10
    bytes but only receive 5. The application would appear to hang waiting for
    the remaining 5 bytes unless you have set timeouts to allow the read to
    abort.
    The fact you need to unplug and re-insert suggests the driver needs to
    reload.
    This could in theory be a result of a surprise disconnect.
    What this means is the device handle is open and the device disappears from
    the PC (like unplugging - but could be an EMC/noise event).
    When the device re-appears to the PC the handle and the hardware no longer
    match as the stack is not maintained during a disconnect.
    This would result in you not talking to the actual device but some "rogue"
    device handle which could theoretically hang the application.
    Some ideas for debug:
    1.
    Verify the driver version installed is 2.04.06
    http://www.ftdichip.com/Drivers/CDM/CDM%202.04.06%20WHQL%20Certified.zip
    2.
    Ensure you have set read and write timeouts in your application
    3.
    Use WM_DeviceChange to determine if you are disconnecting.
    http://msdn.microsoft.com/en-us/library/aa363480.aspx
    4.
    Try increasing the resetpiperetrycount to make the device more immune to
    noise events.
    http://www.ftdichip.com/Documents/AppNotes/AN_AdvancedDriverOptions_(FT_0000
    73).pdf

  • Problem on WinXP / Labview 6.1 with VISA (serial port)

    There is a problem on WinXP / Labview 6.1 with VISA which i use to poll the state lines of the serial port. The only functions that i use are "VISA Open", "Find Resource", line state properties and "VISA close".
    On my own machine (WinME) it works fine as a standalone application (with runtime engine in the same direction), even if i rename the Labview directory so that Labview is not found.
    From my VXIpnp directory i deleted all but these files:
    directory "Win95",
    subdirectory "Bin" containing "NiViAsrl.dll",
    subdirectory "NIvisa" containing "visaconf.dll".
    When shipping this to WinXP (and copying "VXIpnp" to the root directory), the serial port was not found, so i renamed the direction "Win95" to "
    WinNT", but this did not work also.
    I installed the VISA server, although it seems not to be required -- no result.
    Final question:
    What must i do for distributing the program as a standalone application for all windows platforms?

    Hey Joachim,
    In order to create an installer that includes the VISA Run-time engine for serial IO you will have to purchase LabVIEW 7.x. See screen shot. This packages a small compact version of the run-time that can only be used for serial, but it takes up much less space. The installer that I created has my application, the LV Run-time, and the VISA run-time and it is about 26 MB.
    That is much smaller than if I had to include the 32 MB LV 7.1 run-time and the 14 MB VISA run-time separately. It would have been even smaller if I would have uncheck some of the items that I wasn't using.
    -Josh
    Attachments:
    advanced.JPG ‏31 KB

  • How do I process serial port strings as bits

    In response to my commands, my instrument is sending bytes to my serial
    port. In one instance, 2 bytes are received. I want to treat these 2 bytes
    as a group of 16 bits.
    The VISA and Compatibility Serial functions return these bytes from the
    serial port to Labview clearly labelled a "string".
    Everything I can find in the way of Labview functions and .vis don't want to
    do bit twiddling, bit swapping, and bit dropping, with "string" data.
    I thought "hex string to number" could be used here, but I can't find a way.
    The 2 Bytes in question can be represented as hex, but the data are not the
    ASCII codes for the hex representation of a binary number, they are the
    binary number. This "hex string to number" seems to want ASCII c
    odes.
    You can feed a hex number typed into a "control" box wired into "hex string
    to number" and you get a meaningful number. You can feed the 2 bytes from
    the serial port into an "indicator" set to read in hex and you get a hex
    number that is a correct representation. But that is Labview handing them
    around to itself. I need to get my "hands" on them.
    I can't feed those same bytes that show up as a correct hex representation
    in an indicator into the "hex string to number" or anything else, so far,
    and get a number that is useful for further processing.
    I thought "variant to data", but I can't find enough reference material to
    understand how to use it. A boolean array seems like a bit of a weird
    approach, so I thought I'd ask before I looked into that.
    I'm used to dealing directly with binary numbers on the processor stack, I
    call them whatever I want, and turn them into anything I feel like.
    I'm sure I'm staring the solution in the face, but I can't find any way to
    persuade
    Labview to treat this "string" data as 16 bits.
    I've got the 16 bits, which is better than not having them, but I don't have
    much hair left.

    duh, well I finally discovered the "Unflatten from String" function. A guy
    just feeds in the bytes he's collected from his serial port that Labview
    thinks are a "string", and out come lovely little unsigned 16 bit numbers,
    or whatever other type of number he wants to turn the bytes into. And there
    are great little bit twiddlers available after that, like "swap bytes", and
    you can mask out bits with the logic operators, why this is fun. There's
    nothing like being a moron...... fly me to the moon...................
    "David Lewis" wrote in message
    news:[email protected]..
    > The two bytes would come from a serial port read.vi in Labview, classed as
    a
    > string. For instance, D3 and 02. The output wou
    ld swap the two bytes,
    i.e.
    > to 02 and D3, consider the two swapped bytes as 16 bits, drop the six most
    > significant bits, and output the ten bits that are left as an integer
    > classed by Labview as some kind of number, not a string.
    >
    > Your example StringToBits_Converter.vi I found on the ni.com site
    > unfortunately gives an error message and refuses to open on my system
    saying
    > it comes from a newer version of Labview 6 than I am running. Mine says
    > 6.0.1b3. Thank you very much anyway.
    >
    > "FightOnSCTrojan" wrote in message
    > news:[email protected]..
    > > In another words, you want to create a VI in which the input is 2
    > > strings (i.e. AB) and the output is the converted array bits (e.g.
    > > 1010101010101010)?
    >
    >

  • 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

  • Parsing data from Serial Port one byte at a time

    Hi everyone,
            What I want to do is read in from the serial port byte by byte and parse each byte that I am reading in. The size of the data read in varies. How do I do that? I can do using .dll but I want to learn how to do it in labview. I searched through the forum for something similar but no luck. I have seen some that puts the VISA read in a while loop and others that puts the property node,  "bytes at Port" in a while loop. What is the difference in doing either way? I am using Labview 7.1 Can anyone point me in the right direction?
    Thanks

    Hi guys..
    I'm still a beginner in using labview tcp/ip function. for now, i have a project to read the labview data with java programming language so that i can monitor that data using any devices that using java, such as PC or cell phone. my task for now is to determine the format of data that being sent (its type, length, etc), coz as far as i done until now, the data that read in the java is still a raw material so that i dont know how to gain the information from that data.
    my question is :
    - how does the type cast work in changing the data format from one to another?
    - how does the bytes to read in tcp read work? coz when i'm changing the length of bytes to read constant from 4 bytes to another, the data is becoming mess up. As far as i know, the bytes to read only read the first "constant number" byte in the tcp read to determine the length and type of the data..
    thanks

Maybe you are looking for

  • Need help in runtime error

    I try to run the ausp dbtable. with entries of object: 00001019680 and more that 1300 entries Inter char. sr_code classtype: z01 the problem is display in a short dump with this message There is no help text for this runtime error either the text was

  • How do I know if an image has a transparent background when looking in Bridge?

    In Photoshop I can see the transparency grid and so can quickly tell, in bridge I can not see the transparency grid but there must be some way to tell. As an example of my work flow, if I have out put a load of icons which need transparency on them h

  • Duplicate and remove MC's

    I have created a flash movie using actionscript 2.0 when the movie loads, stars burst out from another movie clip in all directions and then the alpha value is pulled down until they are transparent and at that point they are removed, however i need

  • FW: AR Credit memo Application

    hi all, Our cleint is facing following issues. Can you people plz provide some solution.. 1) We have a customer that would like to receive a check for a credit memo rather than a on account credit, is that possible and  how is that done. 2) Also we h

  • Clear the Text  in text editors

    Hi all, I had an requirement like 5 subscreens in a main screen. There i am maintaining text editors into 5  screens. where i am creating the  one editor and using the same for all  the 5 screens. But the problem is when i am changing the tabs for su