Endless SerialPort Reading

Hello there!
I have implemented the code Kevin Le made and it works perfectly.
It is a windows form that allows you to configure, open, read, write and close a COM Port in a wonderful and straightforward way. All of that using the serialPort class.
Due to the nature of my project, I need not only to read it once (through the 'read' button) but to read it as long as I want continously. Basically, I'm receiving data in any moment and I need to be able to capture it and save it into a SQL database (Haven't
figure that yet). Right now, I'm able to capture the buffer by clicking the button and save the data to a .txt file. I just want to make the program an automatically reader.
Any idea?

You are looking for the
DataReceived event on the SerialPort class.  Attach a delegate to that event and it will be called anytime there is data to read.  When your delegate is called, then call the Read method

Similar Messages

  • My application hangs after 10 hours in the serialport read sub-vi. Why?

    My application is programmed under LabView 5.1.1 on a windows 2000 platform.
    I use a MOXA RS232 extending module with a B&B RS485- converter.
    After 10 hours trouble-free working, the application, using semaphores, hangs in the serialport read sub-vi.
    In the same constelation without RS485-converter, once the application hanged up in the serialport write sub-vi. After Restarting LabView I was still not able to access the serial port. So I had to restart the PC.

    I am not sure, but it looks for me as some buffer overflow error.
    Like you read or write something before it is ready.
    Try to play with the lines like DTR and so on.
    regards
    PP
    Isildur wrote:
    >
    > My application is programmed under LabView 5.1.1 on a windows 2000
    > platform.
    > I use a MOXA RS232 extending module with a B&B RS485- converter.
    > After 10 hours trouble-free working, the application, using
    > semaphores, hangs in the serialport read sub-vi.
    > In the same constelation without RS485-converter, once the application
    > hanged up in the serialport write sub-vi. After Restarting LabView I
    > was still not able to access the serial port. So I had to restart the
    > PC.

  • SerialPort Read Timeout

    Anyone knows how to achieve SerialPort Read Timeout? Or in another way to say it, stop reading from the SerialPort.

    Remove the Serialport listener Maybe !

  • Stop endless CD reading...

    hi,
    Is there any way to stop an endless CD reading? Sometimes I put an old CD which is maybe damaged or written in a non Mac format and the Reading take for ever, even if I close all the application it will still keep reading. It is very annoying that I have to restart my Mac, besides I think eventually it might damage the CD unit.
    Any help or ideas on how to cancel that? By the way is there any way to rescue an old file that the CD does not read?
    Best,
    Sebastiao

    I'm having the same problem with software CD's on a MacBook pro. I have two that won't read in my computer but will read in another MacBook pro and my old Pismo power book. When this first happened I though it was a fluke. I was able to install the software by burning a copy on my PC then reading it on the Mac. But I'm now having the problem the Sims 2 Pets game that needs the disk to run. It's not scratched, I just opened the package today.
    I have no problem with DVDs, CD-Rs, DVD+Rs, most CDs and all but my oldest DVD-Rs.
    MATSHITA DVD-R UJ-857:
    Firmware Revision: HAC1

  • Endless Telnet Read Loop

    Hi
    My goal is to constantly archive data to a local machine thru a Telnet connection.  I receive a small amount of streaming data (25 bytes/second) thru a static IP address.  The code that is attached is my attempt to
    1) initiate a Telnet connection to a static IP address
    2) read the streaming data, write to binary file on local machine
    3) send some pertinent info to the screen for the user
    since I always want to have the VI reconnect if the Telnet connection is dropped (or times out), I attempt an "endless" loop that will
    4) close the Telnet connection
    5) reopen the Telnet connection
    6) recommence writing data to binary file on local machine
    My questions are:
    Q1) Did I write this correctly?  Behavior is erratic.  Sometimes works perfectly, sometimes doesn't work.  I am unclear if I need to use a sequence of events within the outer loop to properly reconnect whenever a telnet connection is lost (sequence1: open Telnet, 2: write data. 3: close session, loop back to 1).
    Q2) Often, when there appears to be no successful Telnet connection (by this, I mean no data streams to the screen which indicates the data feed will not be written to a binary file on the local machine), the numbers in the "File Size (bytes)"  continue to increase.  When I open the binary file to see what is being written I find the same character repeated instead of the data I wish to collect.  I think perhaps that the Telnet Read is reading something, but I don't know what it is, or how to control it.  Any ideas?
    Thanks!
    Attachments:
    MBB06RawTelemetry.vi ‏27 KB

    I said stop the inner loop either when the
    button is pressed (as you still have) OR there is an error.  So look at
    the status of the error wire and OR it with the stop button before
    wiring into the inner loops stop terminal.
    Ok. Clear now.
    I'm not sure
    why you'd be getting a stop/continue dialog for error 56 because I
    can't see anywhere in the code that would cause the dialog to pop up. 
    Drop some more indicators on your error wires, or probes.  Run with
    highlight execution turned on.  Do any or all of these things until you
    can figure out where the error is occurring.
    Ok.  I can do this.  More later if necessary.  
    I don't know
    where ^@ would be getting generated from unless somehow the telnet
    protocol is doing it.  What you could do is put a case structue or
    select statement in the middle of the string so that if there is no
    error, the string value goes from the read to the file.  If there is an
    error, an empty string goes to the file.
    What do you mean by "in the middle"?
    Q3: Is it possible that having multiple Telnet sessions open at one time would create issues like this?  The final goal is to archive the telemetered data from 6 stations at once through the telnet port of one machine.
    Go Beavers.

  • Buffered Reader, how to make a loop to terminate

    Hello, the code uses each line from the input.txt and does whatever we want, it's termination condition is when the next line is null. But this fails to work if the input.txt doesn't have an emptyline after the last line, how to change the code to work for those files?
       try {
            BufferedReader in = new BufferedReader(new FileReader("input.txt"));
            String str;
            while ((str = in.readLine()) != null) {
                /*WE DO WHATEVER FOR EACH LINE HERE */
            in.close();
        } catch (IOException e) {
        }Edited by: Odinn on Jan 10, 2009 10:18 AM
    Edited by: Odinn on Jan 10, 2009 10:19 AM

    Odinn wrote:
    Nop, say I have an input.txt file that contains
    1
    2
    3
    4the code above won't work files that the end line isn't empty. It works for:
    1
    2
    3
    4
    <assume theres an empty line here>Edited by: Odinn on Jan 10, 2009 10:37 AM
    Edited by: Odinn on Jan 10, 2009 10:38 AMAre you sure about that? Did you try to run it? If so, what happened? I just ran your code as is (just modified it to print the lines out) with two input files: One with a blank line at the end, and one without. I got the same exact output, and no error messages.
    Odinn wrote:
    the code uses each line from the input.txt and does whatever we want, it's termination condition is when the next line is null. But this fails to work if the input.txt doesn't have an emptyline after the last lineI don't think your logic is correct. A blank line at the end of a text file is not the same as a null, and in fact, it does not fail. If you run the code, you will see that you are not in an endless loop.

  • Adobe Reader freezes after opening a document

    It's a recurrent problem with Adobe Reader.
    Shortly after opening a document, Reader freezes for several seconds. Who knows why, it probably accesses the network, or tries to do something smart, which results in the user being unable to read the document for a while.
    I have tried to disable as many "smart" options as I could, but without success. Could anyone work around this endless Adobe Reader bug?
    I must admit I'm tired of this monster of a program, why can't Adobe keep the Reader a light application, instead of throwing all those unnecessary functions, ads and other uglinesses ... ?

    Hi MB_UK,
    Please update your Reader to latest version, i.e.10.1.3
    Also does the problem exist with a specific PDF's or with each PDF. Please try to open the following PDF:
    http://helpx.adobe.com/content/dam/help/attachments/Acrobat_Reader_ReleaseNote_10.1.3.pdf
    What browser and version are you using?
    If the problem still exists please uninstall Adobe Reader and install it again from:
    http://get.adobe.com/reader/

  • Read master data variable values in fox  before executing the layout

    Hello,
    I do have a requirement that if a user picks up a customer which do not have any account group assigned, the layout cannot be plannable. Account grp is an attribute of customer.I kept this function under function attribute before layout display. It is not giving any message if the selected combination of the variables in the planning data do not have any data. The user should get a message even before the data is entered.
    My basic understanding is that the below function is reading thru transaction data and is not reading the variable values before opening the planning layout under planning folder.
    Any suggestions.. Your help is greatly appreciated.
    Thanks,
    Code is below------
    DATA CUSTOMER TYPE 0CUSTOMER.
    DATA ACCOUNTGRP TYPE ZKATR3.
    CUSTOMER =VARV(CUSTOMER).
    ACCOUNTGRP =ATRV(ZKATR3,CUSTOMER).
    DO.
    IF ACCOUNTGRP = #.
    MESSAGE E003(/SEM/001) WITH '*** CUSTOMER NOT PLANNABLE:*'.
    EXIT.
    ENDIF.
    ENDDO.

    Hey,
    can you tell a little more how you want to use your coding ? I mean is it a fox formula and when it is the case when and how do you execute this function ? And even if you have the right coding, how will you set the accountgrp for a customer that has none assigned ?
    Genenrally your coding (if it will be executed by a fox formular) will check the value of the global variabel 'customer', checks the value of the named attribute. But I think your loop is not 100% right. You have to put the exit statement outside your if statement because if the accountgrp != # it will be an endless loop.

  • How to load XML files ? HELP!

    Hi folks.
    We have an old Oracle database 7.3..
    So we need to load XML files into its tables.
    As we understand Oracle Loader doesn't help us.
    Is the way to load that files?
    Thanks in advance
    Alex

    I know you realize 7.3 is old but this is sort of like trying trying to view a DVD when you only have a VCR. Simple answer would be buy a DVD player, i.e. upgrade to a more recent version of Oracle where you will get many features to handle XML.
    How do you want the XML loaded, all as a single object? That could be a CLOB column if 7.3 had them, I am not sure. You would probably have to write PL/SQL and something with UTL_FILE (if 7.3 had that) to load it.
    If you want to put it multiple columns based on its tags, you would be better off parsing it using PERL (or something) into a CSV and loading that in SQL*Loader.
    I assume as this is using XML it is a reasonably recent design, combining that with an ancient version of the database is just going to lead to endless headaches.

  • Using "Save As" to save an email results in unintelligible TextEdit doc

    People send emails containing news articles and other highly-formatted content from the original source--photos, headlines, indenting, etc. I like to save some of these as documents outside the Mail application. Usually "Save As" creates a perfectly fine TextEdit file. But sometimes (and this can happen with internet content too), there is nothing I can do to get a Text Edit file that is legible. Some of the info is missing, numbered items bear no relation to the real numbering, text at the bottom of a page that's too long just disappears instead of flowing on to the next page. Etc.
    I've tried dragging and copy-&-paste, too. Plus I've tried TextEdit in "wrap to window" mode as well as "wrap to page," noticing no difference. In cases where this happens, it seems those emails simply cannot be saved outside of Mail as ordinary text documents.
    You CAN save an email outside Mail by selecting "Raw Message Source" in the Save As dialog box, but it remains a Mail document and uses the Mail application to open it.
    Does anyone know a workaround for getting this kind of heavily formatted email saved as a TextEdit file, or is it that TextEdit just can't possibly handle every conceivable type of formatting out there?

    What is the source of this highly formatted content: HTML documents, PDF documents, etc.? If it's not PDF documents, why can't you just Print to PDF for those emails? All formatting is retained, along with legible text.
    is it that TextEdit just can't possibly handle every conceivable type of formatting out there?
    No, it can't; there isn't any program that can handle every conceivable formatting specification. Expecting one will lead you to endless disappointment.

  • ITunes Match colapse in step 2

    When I add new songs to itunes and update itunes match the process freeze in step 2 when almost check all songs except 1 or 2

    Same boat here. Tried three times over the weekend, each time it claims to have processed 10908 items (out of 11023 in my Library), 0 items remaining. No progress after that, though iTunes has been uploading several hundred K per second for the last several hours. Maybe it's uploading my unmatched stuff? Who knows?
    Doesn't inspire a lot of confidence in their cloud strategy overall if they can't get even get music matching working in a reasonable amount of time. It's been in beta for a couple months, shouldn't be this slow, definitely shouldn't be this uncommunicative about what it's doing.
    At the very least it should indicate that everything's going ok and eventually it will complete. Right now I simply have no idea if it's working or just caught in an endless loop.

  • Any way to smoothly transition from animation to a menu?

    My DVD starts with an animation that, when it ends, forms the main menu background. The problem I'm having is that the only way I know to set up the DVD is to have it pause awkwardly in between the end of the animation and the menu background. This is my setup: I have the opening animation as the source of a track which then connects to the main menu with has the background graphic as its source.
    Is there any way around this so that the animation plays seamlessly into the main menu without the pause? Is there is a way to make the background for the main menu the entire, single animation, then somehow "turn on" the buttons and overlay file once the opening part is over and it settles to form the main menu background?

    Yes. You need to create one single video (in FCP) that is your opening animation that leads to your menu animation (you need to put all of your graphics in FCP, not DVD SP). Put a chapter marker at the point you want your buttons to pop on. Create an overlay file for your buttons. Sending the video to Compressor to encode as a m2v file. Then bring the .m2v and your overlay file into DVD SP, and drop them into your menu. Then set the loop point at your chapter marker.
    Now when someone plays your DVD, they will see what is before the loop point once and it will seamlessly go into the second half of your menu, which will endlessly loop.

  • How can I use interupts in Labview

    void main() {
    while(1) { // the program wil work forever
    if( button_Send == true) // the program wil execute send if the 'send button' is true
    send();
    else // if the button is false the program will read
    read();
    void serial() {
    blabla...
    void read() {
    wait for character...
    blabla...
    this is what I made but as you might understand the program will hang in the read loop if theire is no character
    to receive. this is what I had in mind but how can I do this in LV? I read something about vi prioreties...
    anable interupt at serial port: // enable interupt
    if( RXADRESS /= 0 ) { // chack if read buffer is not empty
    void read(); // then read.
    void main() {
    while(1) { // the program wil work forever
    if( button_Send == true) // the program wil execute send if the 'send button' is true
    send();
    else // if the button is false the program will wait for the
    // send button or the interupt to accure
    nothing..
    void serial() {
    wait for serial line to clear...
    send char...
    void read() {
    if( RXADRESS /= 0 )
    wait for character... // check if the read buffer is not empty
    else
    return.

    Hi Memmo,
    I assume when you say "Lightbold", you mean the highlighting tool in the LAbVIEW development environment.....
    I also don't know if you have now implemented the serial communication in LAbVIEW or some other language, but I'll assume you've implemented it in LAbVIEW.
    A typical reason for code working in "slow-mode" and not at full speed is some kind of timing problem within the code.
    One suggestion I have is to first check the serial receive buffer before reading from the serial port. You can do this using the "Bytes at serial port" property of the VISA connection (I strongly advse using VISA if you're not already doing this). By wiring the "number of bytes" in the buffer to the read function, you only actually read what's already there. This way you skip the endless serial reads when nothing is there to read.
    Since you are now looping a serial buffer query instead of getting stuck in a serial read dead-end, you can incorporate a stop criteria in your read loop (Either a stop button or a timeout). This should solve the problem of your program becoming non-responsive in the case of no data being sent to the serial port.
    As to why exactly you are not always receiving the correct text, without code to look at, it's kind of impossible to guess where the problem might be. If you could post a picture of your block diagram, I'm sure someone can help pretty quickly.
    Hope this helps
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    VI example 2.png ‏11 KB

  • Hidden Folders showing up in Color directory browser

    Are the hidden folders supposed to show up when i browse my directories from within Color?
    is this the way the program is supposed to work?
    Anyone know is this is a bug and if it is will there be a fix for it soon?
    thank you in advance,
    ~X

    Yep, they do. Color's not alone in this of course, but it does add to the clutter of navigation that's difficult enough without endless scrolling.

  • Photoshop CC Save for Web Greyed out

    After the last Creative Cloud Photoshop update my Photoshop CC 64 bit save for web is greyed out and I can no longer save as a png. Using Windows 7
    How can I correct this.
    thanks,
    Buddy

    I have the same problem. Save for web grayed out no matter what. Also photoshop denies opening any png file, also the png format sometimes doesn't even appear in Save as.
    I can import png by choosing Open As and selecting Camera Raw. But then I can't save as png again. QC slacking at Adobe or what? Never experienced these kinds of difficulties with earlier versions. Might just as well brush off my old CS4 masters collection.
    Will try a reinstall although I frankly don't have the time to wait for the endless download.

Maybe you are looking for

  • How to turn off lumia520 time display on the scree...

    How do i turn it off? I just want to have the date display on the block screen. I have a watch so i dont want to look at the time on the phone. Also, how do i turn the lady's voice off when i am receiving a call? She keeps saying: call from ####.

  • Item code change into another item code

    Hi friends, problem situation:- i am having X item in A warehouse,i realised that now that is not going to sell, then there are Y item in B warehouse, in know that if i make X as aY1 and transfer to B warehouse it is going to sell(IS IT POSSIBLE TO M

  • Loadrunner 11 and Adobe interactive forms

    I'm currently on-site for SAP Italy and the client wants to use Loadrunner 11 to test a business process that requires Adobe interactive forms. eCATT is not acceptable to the client Can you advise me if the question about this being possible using Lo

  • Order list from purchasing list item

    Hi All Retail expert, I have created purchasing list item. Now when i am releasing purchasing list thru wrfapc12, no order list created . only message comes ..please purchase list . Kindly suggest. I am really stuck where i am missing. With Thanks &

  • Moldwise SPC analysis

    My requirement is to capture Diameter of a product during in-process inspection. Product is manufactured in different moulds, its glass manufacturing industry. Client requirement is to mould wise study of SPC for characteristic "Diameter" during in-p