COM port reading and writing

Attached VI, a while loop executes sub 4 screws... The data read in the COM Port; Analysis of the data, prepare the response packet and send response to Port COM... It does not (I think that's not reading the data at regular intervals) to certain commands a few times... Can anyone suggest me two different ways of programming that, I thought using the queue and 2 all in loops (reading data and analysis in a loop, write in the 2nd loop analysis and Com Port)... But my class given Com Port number; Don't know how I share between 2 parallel loops for the queue.

Kind regards

Chandra

My original with objects Code works perfectly with a delay in the while loop; Thank you for pointing me in this direction...

Tags: NI Software

Similar Questions

  • Questions about serial port read and write at the same time

    Hi I create a user interface for the communication serial port, where there are essentially 2 front panels, where the user enters commands one and the other where the prints of UART is delivered. I thought initially using a state machine but the reading and writing may be independent sometimes and so I can't rely on States. I searched a bit on the forum and he left me even more confused. Help, please.

    (1) in a thread that sessions visa duplicated has been used for writing and reading at the same time, is it recommendable? How will this affect performance?

    (2) essentially when the vi is reading data are it must constantly view as well, however, someone said that it takes too much memory to use shift registers, so how do I go about this? If using a State in queue after the loop of reading it affects the playback loop and be sequential?

    In addition anyway is to move the cursor to the latest data from the indicator

    (3) for the control of the user input, assumes that the user has entered an order in the control and press ENTER, then writing visa is launched, but if it comes in another string and press enter then write must be called again... is - it possible? will detect the previous commands in the control of compensation?

    (4) according to my understand the expectation for the event do not monopolize resources and writing can go in parallel, am I right?

    Thank you. I have attached a very basic vi which took me to the point, but I want to make it more robust. Please help especially in the part of the user interface.

    su_a,

    (1) you can have only one session to a port. Several UART can handle full duplex so performance is not affected.  At flow rates of high data and large amounts of data, buffering and latencies of BONE can become a problem.

    (2) who told you that shift registers using too much memory? Shift registers are usually the best way to transfer data from one iteration to another. String concatenation inside a loop (registry to offset or not) causes the chain to develop and may require re-allocation of memory.  Your VI never clears the string so its cold length become very large.

    Generally, you do not have an active cursor on an indicator.  If you want to always display the most recently received characters and turn on the vertical scroll bar use a property node to keep scrolls to the bottom.  This can be annoying for users if they attempt to manually move the scroll bar and find that the program continues to move it back automatically.

    (3) if the user has changed the value in the chain of command, when he hits enter the modified value event fires.  Simply strike brace does not change the value and does not trigger the event.  Not control need to be erased, but the value that he has to change.  If you want to send the same command again, have a button send a command may be a better choice.

    (4) write is a case of the event.  It is not in parallel with anything.  The structure of the event do not monopolize resources.  The other loop will run while it waits.

    The event loop will not stop when you press the STOP button. Probably it wll take two command: change events of value after JUDGMENT before any loop stops.  Replace the Timeout event (which never expires) with a STOP: value change event and a real wire of this judgment to the Terminal endpoint.  Remove the local variable.  Make mechanical locking when released.

    Lynn

  • simultaneous reading and writing on a PDM file

    I found similar discussions on here, but none that satisfied my problem. I'm running several loops within a vi, which writes data in a permanently .tdms file. Another loop to finish its task from the start in a test, and I want to transition this loop so that it accesses the file writing and started writing on a network. It also enables me to check that the data is being stored in the file and that it is corrupt.

    I started with just the basics, but when I pass the second loop to read the file that is is always written off mistakes, saying that she met at the end of the file. It does if I put the count 1, -1 or anything in between. It illuminates, however, the end of the file output.

    I have the entry in the file tdms on PDM read wired to a local variable, just as I do writing PDM, they all have both read the same thing and I get an iterations of a data value of the reading, so, apparently, file access is no problem. And I have to someone who cringed to local variables, ensure that reading and writing are not activated until the local variable is updated.

    Try to set the "group name" entry on «TDMS read» If you write more than one group, you can use "View the contents of the DDHN" in order to get a list of groups.

    Herbert

  • simultaneous reading and writing files TDMS

    A customer had a program written in 8.6; the programmer is no longer available and I'm looking to debug intermittent problems.

    N - channels of data is acquired and streamed to a PDM file. The operator can select a channel to view data in real time, but the display is one scope table displaying 15 seconds worth of data and when switching of channels the program "returns" display with the last 15 seconds of a data value of the new string (barrier data extracted from the TDMS file).

    What I notice here, aside from using sloppy cluster error, is that both references are open in the file - one for writing data and the other for recovery data. Is this a good practice? is it necessary or one reference supports the reading and writing? Is this a possible source of problems?

    thanx

    lmd2

    You can do the same thing with a single file reference.

    The issue of not being able to see the data that was written after the reading of reference has been opened is known for having refnums to open in two different processes, but not in the same executable or VI.

    Herbert

  • Reading and writing data XML of BC4J

    Hello!

    I try to reproduce "27.7 reading and writing XML data" chapter of 'Developer Framework of developing applications for forms/4GL developers's Guide. "
    Our intention is to read and write at first only XML.
    However, it seems that we need this chapter a database connection.
    To shorten this assessment - is it possible to adf bc only with xml?

    Kind regards
    Torsten

    The solution is described in "27.8 Using programmatic view objects from other Sources of data" in the doc you mentioned. If you use programmatic EO/VO you can do almost what you what to store data. We use xml for some data (but always store in the DB) and read it.

    Timo

  • Reading and writing VISA function

    Hi all

    I am trying to record data from Server series (which has 16 ports) through com ports (I use total 7 ports).

    Here, I'd understand the VISA service.

    Question 1

    If I want to just save data (from the server), can I still write VISA function to read from COM1?

    Or

    Can I just use VISA based only on read and read the string of com port data?

    Question 2

    After I save data of type string, I'll save in a text file.

    But what I see inside the save file is just a raw string of data (which I can't read).

    How to cut data type string in different reading (different record like the tension, the ammeter reading and on/off switch)?

    Please advise...

    Question 1 – it depends on what is the other end of the serial port. If it's broadcasting data all the time, a reading is all you need. If she needs a command to send you information, then you will need both. Look at the definition of communication protocol for what you are trying to read.

    Question 2 - do you need to format. There are a lot of string screws on the palette of the string manipulation, not knowing how the string is formatted at all to start I can not give you advice more than that. An example of the way you write to file, and what you do with the data received can be useful... If the data is coming from a long series, if all goes well there are separators and a chain analysis helps you to highlight if you need to. If you read each port in turn and concatanting just a string, put a constant of the tab between them (available on the palette of strings), or no matter what other delimiter you want to use for that matter. Otherwise, if they are all in the field of fixed-length subset of string vi could be a way to go.

  • Reading and writing Excel File

    Hi all. I need your help. I need to know how to read EXCEL FILE and insert it into a table of some. Also, can someone tell me how to write in an EXCEL FILE?

    Thank you in advance.

    READING EXCEL
    There are several options how read file - ODBC, excel on a fly--> conversion to CSV excel (if you have 11.2 and you want to use tables external preprocessor),... I put (I think all) of the options on my BLOG http://jiri.wordpress.com/2010/01/04/load-ms-excel-file-to-oracle-database/

    WRITING IN EXCEL
    Writing in excel is delicate because there is no direct way of Oracle, here are a few tips

    1 JAVA - you can create java stored procedure, I did not test this, but it's probably doable http://www.java-tips.org/other-api-tips/jexcel/how-to-create-an-excel-file.html

    2. XML Excel format - you can use UTL_FILE and writing to XML Excel can read http://blogs.msdn.com/b/brian_jones/archive/2005/06/27/433152.aspx

    3 Excel also reads the CSV files, but it's file plan text without formatting. You can use UTL_FILE to easily create a CSV (comma-delimited) file and read from excel, I have some examples on my blog http://jiri.wordpress.com/2009/03/18/oracle-fast-parallel-data-unload-into-ascii-files/

  • What is error 39 in reading and writing media and how can I fix this windows xp

    I / ve worked with a compaq pc and when I look at my device manager my read and write devices has a yellow flag on them. I uninstalled sought a driver more recent all posible so far. the computer reads the plug and Play, but then I get this error 39 thing. I'm no guy warned, but I can read instructions. CAN SOMEONE PLEASE HELP. IT WILL BE GREATLY APPRECIATED.

    http://support.Microsoft.com/mats/cd_dvd_drive_problems/en-us

  • Mr. Fix it cannot fix the DVD/CD, reading and writing problem

    I had a problem a few months ago this onc I put a CD in the CD/DVD drive, it can't read and rejected and ask to put a readable CD, then I run Mr. Fix and the problem disappeared. recently just the same problem, I tried Mr.Fix but it cannot solve the problem, then it is there another way to solve the problem

    Best regards

    Ramzi salameh

    Hello

    Step 1: Please do all the same underneath if you did some before as it is often the set of operations which solves the problem.

    Try this double click Control Panel - Device Manager - CD/DVD - device - tab - click on update drivers (this will probably do nothing) - then RIGHT click the drive of the driver - UNINSTALL - REBOOT this will refresh the default driver stack. Even if the reader does not appear to continue below.

    Then work your way through these - don't forget the drive might be bad, might have a cable loose or slight corrosion on the contacts (usually for a laptop) and other issues.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs
    http://support.microsoft.com/kb/314060 - a Mr Fixit

    Try this fix manually if the Fixit 314060 does not work
    http://www.pchell.com/hardware/cd_drive_error_code_39.shtml

    Your CD or DVD drive is missing or is not recognized by Windows or other programs - a Mr Fixit
    http://support.Microsoft.com/kb/982116

    The CD drive or the DVD drive does not work as expected on a computer that you upgraded to Windows Vista
    http://support.Microsoft.com/kb/929461

    When you insert a CD or a DVD, Windows Vista may not recognize the disc
    http://support.Microsoft.com/kb/939052

    Your CD or DVD drive cannot read or write media - A Mr Fixit
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    CD/DVD drive does not appear in Windows Vista, or you receive this error during the installation of Windows Vista after booting from the DVD (AHCI)
    http://support.Microsoft.com/kb/952951
    Drive CD - R or CD - RW Drive is not recognized as a recordable device
    http://support.Microsoft.com/kb/316529/

    Hardware devices not detected or not working - A Mr Fixit
    http://support.Microsoft.com/GP/hardware_device_problems

    Another possibility is that the cables are loose. Remove ALL power, then make sure that the cables at both ends. Remove and replace, do not just tight. For laptops, you can often clean power and contacts data with a pencil eraser.

    Some DVD players do not use the Windows default drivers so check with the system manufacturer and the manufacturer of the device to see if there is a firmware or drivers for your drive if necessary.

    ===============================

    Step 2: You have disc problems as the CD/DVD is actually 4 discs in 1 case (burn CD & DVD and CD and DVD read). Therefore, it is not unusual for 1 or 2 rooms with not so work that others do it properly.

    Did you follow the Troubleshooting Guide for the reader who still does not work? There are some entries in the registry that the troubleshooter does not solve, and those who "could" be the cause.

    Check with your system manufacturer Maker and device for possible firmware updates and the correct registry entries for your car.

    These are the keys in my opinion, are those in question - secondary-keys for the CD/DVD drive of course because there will be other subkeys in these keys. Be sure to ask specific keys involved as well as the parameters.

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\System\CurrentControlSet\Enum\IDE

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ {4D36E965-E325-11CE-BFC1-08002BE10318}

    -----------------------------------------------------------------------

    You can probably find more information here and maybe even registry settings correct for your CD/DVD from someone with the same drive model.

    Forums - much real experts help and hardware information
    http://Club.myce.com/

    I hope this helps.
    --------------------------------------------------------------------------------------------
    Rob Brown - Microsoft MVP<- profile="" -="" windows="" and="" devices="" for="" it :="" bicycle="" -="" mark="" twain="" said="" it="">

  • TSST corp CDDVDW TS-L633B stopped reading and writing

    I have a laptop Acer 4736Z with a TSST corp CDDVDW TS-L633B DVD - RW, so decide simply ceased to read and write DVDs and CDs. When I insert a blank dvd, it will ask me to burn files to it but when I do, it complements the habit and will the useless DVDs. When I insert CD or DVD, the drive does not read it more.

    Please help me on how to solve this problem.
    Thank you

    Hello

    You have disk problems as the CD/DVD is actually 4 discs in 1 case (CD & DVD burning and)
    Playback of CD and DVD). So it is not unusual for parts from 1 or 2 to not work so that others do
    correctly.

    Burning at low speed, or by using the master could help. A CD/DVD cleaner might help.

    Brand of the CD or DVD drive can also be the problem. Low quality (cheap brands) are always problematic.

    CD/DVDs have a tolerance + - and your can read/write on the edge outside these discs
    tolerances. They may be delivered, but it is generally more economical to replace the disk.

    Several good info here:
    http://Club.myce.com/

    CD/DVD units
    http://www.myce.com/storage/

    Notes on the troubleshooting and repair of readers of compact disks and CD-ROM Drives
    http://www.repairfaq.org/repair/F_cdfaq7.html#CDFAQ_014

    ===========================================

    This troubleshooting might not help if there are problems of alignment and wear it
    is worth it.

    Step 1: Please do all the same underneath if you did some before as is often total
    a process that solves the problem.

    Try this - Panel - Device Manager - CD/DVD - double-click the device - driver
    Tab: click on update drivers (this will probably do nothing) - then do a CLICK RIGHT to the road.
    UNINSTALL - REBOOT this will refresh the default driver stack. Even if the disc is not
    shown continue below.

    Then, work your way through these - don't forget the drive might be bad, could be a coward
    cable or slight corrosion on the contacts (usually for a laptop) and other issues.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs
    http://support.microsoft.com/kb/314060 - a Mr Fixit

    Try this fix manually if the Fixit 314060 does not work
    http://www.pchell.com/hardware/cd_drive_error_code_39.shtml

    Your CD or DVD drive is missing or is not recognized by Windows or other
    programs - a Mr Fixit
    http://support.Microsoft.com/kb/982116

    The CD drive or the DVD drive does not work as expected on a computer that you
    upgrade to Windows Vista
    http://support.Microsoft.com/kb/929461

    When you insert a CD or a DVD, Windows Vista may not recognize the disc
    http://support.Microsoft.com/kb/939052

    Your CD or DVD drive cannot read or write media - A Mr Fixit
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    CD/DVD drive does not appear in Windows Vista, or you receive this error during the
    Setup Windows Vista after booting from the DVD (AHCI)
    http://support.Microsoft.com/kb/952951
    Drive CD - R or CD - RW Drive is not recognized as a recordable device
    http://support.Microsoft.com/kb/316529/

    Hardware devices not detected or not working - A Mr Fixit
    http://support.Microsoft.com/GP/hardware_device_problems

    Another possibility is that the cables are loose. Remove ALL power, then check
    in both ends of the cables. Remove and replace, do not just tight. For portable computers, you can
    Often, clean power and contacts data with a pencil eraser.

    Some DVD players do not use the Windows default drivers so check with the system
    Designer and manufacturer of device to see if there is a firmware or drivers for your drive if necessary.

    ===============================

    Step 2: You have disc problems as the CD/DVD is actually 4 discs in 1 case
    (Read burn CD & DVD and CD and DVD). It's not unusual for 1 or 2 parts to not
    function, while others do so correctly.

    Did you follow the Troubleshooting Guide for the reader who still does not work? There are
    some registry entries that do not fix the resolution of problems and those who 'could' be the
    cause.

    Check with your system manufacturer Maker and device for these two possible firmware updates
    and the correct registry entries for your car.

    Here are the keys in my opinion, are those in question - for the subkeys of the CD/DVD drive
    of course there will be other subkeys in these keys. Do not forget to ask specific keys
    in question as well as the parameters.

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\System\CurrentControlSet\Enum\IDE

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ {4D36E965-E325-11CE-BFC1-08002BE10318}

    -----------------------------------------------------------------------

    You can probably find more info here and maybe even right for registry settings
    your CD/DVD from someone with the same drive model.

    Forums - a lot of expert real help
    http://Club.myce.com/

    CD/DVD units
    http://www.myce.com/storage/

    Use DevManView to locate the CD/DVD in the registry (be careful and do a prior Restore Point)
    nothing change) - find the DevManView device and then make a right click on it free in RegEdit.

    DevManView - free - an alternative to the standard Windows Device Manager,
    that displays all devices and their properties in flat table, instead of the tree viewer
    http://www.NirSoft.NET/utils/device_manager_view.html

    I hope this helps.

  • reading and writing to the file on SD card

    I am currently using this code to read and write to files (credit is not because of me - I found these on the Board somewhere):

       private void writeFile(String data, String filePath)
        {
            try
            {
                FileConnection conn = (FileConnection)Connector.open(filePath,Connector.READ_WRITE);
                if (!conn.exists())
                {
                    Dialog.alert("No File Present Click to Create");
                    conn.create();
                }
    
                OutputStream out = conn.openOutputStream();
                byte[] b = data.trim().getBytes();
                String sb = new String(b);
                System.out.println("Bytes to String: " + sb);
    
                if(sb.length() == 0 )
                    System.out.println("String length is zero");
                else
                    System.out.println("String length is not zero" + sb.length());
    
                if(conn.canWrite())
                {
                    Dialog.alert("Writing");
                    out.write(b,0,sb.length());
                }
                else
                    System.out.println("Cannot write to this file");
    
                System.out.println("File Size is : "+ conn.fileSize());
                out.flush();
                out.close();
            }
            catch(Exception io)
            {
                test.setText("Exceptino Thrown from File" +io);
            }
    
        }
    
        private String readFile(String filePath)
        {
            try
            {
                FileConnection fconn = (FileConnection)Connector.open(filePath, Connector.READ);
                if (fconn.exists())
                {
                    InputStream input = fconn.openInputStream();
    
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    int j = 0;
                    while((j=input.read()) != -1) {
                        baos.write(j);
                    }
                    byte[] data = baos.toByteArray();
                    input.close();
    
                    String output = new String(data);
                    System.out.println("Output" + output);
    
                    fconn.close();
                    return output;
                }
                else
                {
                    System.out.println("File does not exist");
                    fconn.close();
                    return null;
                }
            }
            catch (Exception ioe) {
    
               System.out.println("Error:   " + ioe.toString());
               return null;
            }
    
        }
    

    When I try to write a string to a file and then read it again, I get a NullPointerException. When I check the folder that mimicks card SD card on my pc, there is no file created. is the above code ok?

    P.S. I use a simulator of the OS 5.0 and the SD card directory is configured to be somewhere on my desk.

    It is incredibly baroque and inefficient code for a simple job; be happy that you do not claim credit for it.

    A problem may be that the FileConnection in writeFile is not closed. I would rewrite the mess like this (leaving a part of the diagnostic output):

    private void writeFile(String data, String filePath) {  data = data.trim();  OutputStream out = null;  FileConnection conn = null;  try {     conn = (FileConnection) Connector.open(filePath,Connector.READ_WRITE);    if (!conn.exists()) {      conn.create();    }    OutputStream out = conn.openOutputStream();    // it might be advisable to specify an encoding on the next line.    out.write(data.getBytes());  } catch (Exception io) {    test.setText("Exception Thrown from File " + io);  } finally {    if (out != null) try { out.close(); } catch (IOException ignored) {}    if (fconn != null) try { fconn.close(); } catch (IOException ignored) {}  }}
    
    private String readFile(String filePath) {  String result = null;  InputStream input = null;  FileConnection conn = null;  try {    fconn = (FileConnection) Connector.open(filePath, Connector.READ);    if (fconn.exists()) {      input = fconn.openInputStream();      byte[] bytes = IOUtilities.streamToBytes(input);      // it might be advisable to specify an encoding on the next line.      result = new String(bytes);    } else {      System.out.println("File does not exist");    }  } catch (Exception ioe) {    System.out.println("Error: " + ioe.toString());  } finally {    if (input != null) try { input.close(); } catch (IOException ignored) {}    if (fconn != null) try { fconn.close(); } catch (IOException ignored) {}  }  return result;}
    
  • Why my drive hard Boot keep reading and writing for 20 minutes after the start?

    As the title says my HDD Boot continues to read and write for about 20 minutes after the start. Read and write up to 10 GB in the process. I would say a good way to destroy a disc. I have not seen this behavior in any other OS.

    10.10.5 OS version

    Model: Mac Pro

    ID: MacPro3, 1

    Processor: Intel Quad-Core Xeon

    Number of processors: 2

    Total number of cores: 8

    (Vivid RAM) memory: 8 GB

    Any help will be greatly appreciated.

    Thank you.

    Check Console.app and see what happens.   Could be something of a time Machine for Spotlight indexing to a process of runaway of an OS X or a bug in the application.

  • Reading and writing a file

    I'm trying to read and write to a file so that I can store a string array and a double in my application, but I came out a few problems; Firstly when I put my path in the constant path he will say that the file is not there never be (so I have to force the issue and when the application requests a file I have to browse and add files), secondly when I run the program and it reads in the file it does not display the strings or double immediately instead , I must hit the submit button and what they finally, finally arrive when I reset my values in the .txt files and put in my thong and double and press on submit table jumps in one place and starts at index 1 (array [1]) if anyone can help I would appreciate it a lot.

    Here is my code:

    That's what I wanted to say on the structure of the event and it should take your second problem.  I don't see the third one.  I saw no flicker, but I have a slight vision problem which means I do not waver.  So he can sparkle.  Or maybe not.

  • How use the serial port read and display the text but not scroll off the screen?

    I'm new-ish/return user fan of Labview and trying to change the example VI "Advanced serial write and read VI" is the part of the dev suite 2012.  I need to use the string box for ALL of the text from a serial port, always adding and just roll off the screen when the actuals come to the serial port.

    What actually arrived more than bytes (or no bytes AT ALL!), during reading time text, current rolls out of the box in the chain.  Even when receiving 0 bytes, screen is removed.  I'm not very familiar with the locations of functions and even worse to understand obscure references to functions, so please keep very basic answers so I can follow.

    Just to be clear, I need window of the chain behave as HyperTerminal does always displays the data and it is not pushed by window arbitrarily.

    Thank you

    Steve

    A long shot.

    Is that what you want?

  • reading and writing series sometimes works, sometimes expires

    I use the series on the VIs VISA to acquire data through an instrument.  After you have configured the port, I have send the instrument the order "AZK" followed of a newline (string hex "2A 61 7A6B 0D").  This brings the instrument to trasmit data.  When I do this in Hyperterminal with the same port settings, it works every time when I repeat the command as quickly as I can without any problem.  When I start my VI in LabVIEW, sometimes it works and sometimes it isn't (work maybe 25% of the time).  When it works, the data are displayed in an indicator very quickly.  When it doesn't work, I get a timeout error (10 seconds).

    I think the data string is ~ 330 bytes; Since I'm troubleshooting, I have it reduced to 20 bytes in order to ensure that the reading series is not waiting for more of bytes.  I also tried to extend the timeout, but it doesn't help.  Thinking this was maybe timing, sequence, or buffer related, I also tried to write and read in frames separated from one frame of the sequence and also tried an initial framework with clear VISA to clear the buffers before writing and reading, but none of this has helped.

    Any ideas why this might work a while but not others?

    I have attached a VI that I use to try to get this working.  (Note some data, the analysis of operations, as well as the VISA read a previous VI, but they have not been configured for this instrument of entry again and only the input string of reading indicator is significant at this time).

    If I can't get this to work, my rescue is rule automatically the instrument on trasmit on a certain frequency (like 1 sec) and acquire these data.  I was able to do this successfully with another device series.  But I wanted to be able to have LabVIEW to control the timing of transmission data as this unit has this capability.

    Thanks for any help.

    You can try adding a delay between characters like Hyperterminal does.

    And please don't say that you use the continuous run button. That would be a mistake.

Maybe you are looking for