RS232 data logging

I am trying to modify the example VI for RS232 read for data logging. Basically, trying to record my measuring guage reading data with time stamp.  My modified VI logs the data but it saves only last value before i stopped the program, whereas i want it to keep reading and logging data until I stop. I am not sure where I am going wrong. I am attaching my VI with this post. could anybody help me out please.
Kudos are (always) welcome for the good post. :-)
Solved!
Go to Solution.
Attachments:
Guage data logging.vi ‏39 KB

Never mind, just figured what I was doing wrong. The create file function was in the loop so each interval it was making new file, overwritting on the previous one thus earasing all previous data but the last data point.
Kudos are (always) welcome for the good post. :-)

Similar Messages

  • How can I display only the Data Logging pull down menu on my LV front panel?

    Is it possible to hide all unused pull down menu on my front panel vi like File, Edit, View etc.. and only
    display the pull down menu for the Data logging?!
    best regards
                          Norick

    Hey,
    You can build your own runtime menu (Edit>runtime menu) and then e.g. only display the application items you want to.
    Christian

  • How can I perform data logging for a specific time??

    hello everyone,
    I am quite new in labview and I have a basic question regarding data logging. Currently I am using a cRIO9074 and doing some data logging for my test. The data logging it self works ok so far.
    But my problem is I would like to write my datas in a text file either for a specific time interval (ex)10 seconds) or for a specific amounts of data (ex)500 Samples). Can anyone give me some help regarding my problem?? Attached you can find my RT.vi 
    I would appreciate for anyhelp!
    Regards
    Yun 
    Attachments:
    BP250 Encoder Position & Velocity (Host).vi ‏92 KB

    Run your loggging program for that time. When your program terminates then it will write all the logged data so far in text file.
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet

  • How do I control a data log session with period and sample time?

    I need a data logging system where the operator can select 2 logging parameters: Log Period and Sample Time. I also need a START and STOP button to control the logging session. For example, set the log period for 1 hour and the sampling time for 1 second. (I may be using the wrong jargon here.) In this case when the START button is clicked, the system starts logging for 1 second. An hour later, it logs data for another second, and so on until the operator clicks the STOP button. (I will also include a time limit so the logging session will automatically stop after a certain amount of time has elapsed.)
    It’s important that when the STOP button is clicked, that the system promptly stops logging. I cannot have the operator wait for up to an hour.
    Note that a logging session could last for several days. The application here involves a ship towing a barge at sea where they want to monitor and data log tow line tension. While the system is logging, I need the graph X-axis (autoscaled) to show the date and time. (I’m having trouble getting the graph to show the correct date and time.) For this application, I also need the system to promptly start data logging at a continuous high rate during alarm conditions.
    Of course I need to archive the data and retrieve it later for analysis. I think this part I can handle.
    Please make a recommendation for program control and provide sample code if you can. It’s the program control concepts that I think I mostly need help here. I also wish to use the Strip Chart Update Mode so the operator can easily view the entire logging session.
    DAQ Hardware: Not Selected Yet
    LabVIEW Version: 6.1 (Feel free to recommend a v7 solution because I need to soon get it anyway.)
    Operating System: Win 2000
    In summary:
    How do I control a graphing (data log) session for both period and sample time?
    How do I stop the session without having to wait for the period to end?
    How do I automatically interrupt and control a session during alarm conditions?
    Does it make a difference if there is more than one graph (or chart) involved where there are variable sample rates?
    Thanks,
    Dave

    Hello Dave,
    Sounds like you have quite the system to set up here. It doesn�t look like you are doing anything terribly complicated. You should be able to modify different examples for the different parts of your application. Examples are always the best place to start.
    For analog input, the �Cont Acq&Chart (buffered).vi� example is a great place to start. You can set the scan rate (scans/second) and how many different input channels you want to acquire. This example has its own stop button; it should be a simple matter to add a manual start button. To manually set how long the application runs, you could add a 100 ms delay to each iteration of the while loop (recommended anyway to allow processor to multi-task) and add a control that sets the number
    of iterations of the while loop.
    For logging data, a great example is the �Cont Acq to File (binary).vi� example.
    For different sample rate for different input lines, you could use two parallel loops both running the first example mentioned above. The data would not be able to be displayed on the same graph, however.
    If you have more specific questions about any of the different parts of your application, let me know and I�ll b happy to look further into it.
    Have a nice day!
    Robert M
    Applications Engineer
    National Instruments
    Robert Mortensen
    Software Engineer
    National Instruments

  • With journaling, I have found that my computer is saving a large amount of data, logs of all the changes I make to files; how can I clean up these logs?

    With journaling, I have found that my computer is saving a large amount of data, logs of all the changes I make to files; how can I clean up these logs?
    For example, in Notes, I have written three notes; however if I click on 'All On My Mac' on the side bar, I see about 10 different versions of each note I make, it saves a version every time I add or delete a sentence.
    I also noticed, that when I write an email, Mail saves about 10 or more draft versions before the final is sent.
    I understand that all this journaling provides a level of security, and prevents data lost; but I was wondering, is there a function to clean up journal logs once in a while?
    Thanks
    Roz

    Are you using Microsoft word?  Microsoft thinks the users are idiots. They put up a lot of pointless messages that annoy & worry users.  I have seen this message from Microsoft word.  It's annoying.
    As BDaqua points out...
    When you copy information via edit > copy,  command + c, edit > cut, or command +x, you place the information on the clipboard. When you paste information, edit > paste or command + v, you copy information from the clipboard to your data file.
    If you edit > cut or command + x and you do not paste the information and you quite Word, you could be loosing information.  Microsoft is very worried about this. When you quite Word, Microsoft checks if there is information on the clipboard & if so, Microsoft puts out this message.
    You should be saving your work more than once a day. I'd save every 5 minutes.  command + s does a save.
    Robert

  • Help please: DAQWare or data logging software (multichannel data capture) questions

    I am writing regarding DAQWare, data logging software, and the PC-LPM-16
    board, which a group of us a trying to come to grips with. This is rather
    lengthy, I'm afraid...
    We are a group of college students in a computer programmer/analyst
    program. We have a course that involves doing a project to go through the
    software development lifecycle (or as much of it as can be done in a term).
    For our project we teamed up with a group in the industrial hygiene
    program; they have a computer (standalone) with a PC-LPM-16 (PnP) DAQ board
    and the NI-DAQ software (all of this has been around for a few years, but
    has not been used much), and our goal was to capture the data they are
    measuring (atmospheric pollutants) to an Microsoft Access database.
    We are not familiar with DAQ systems, but were shown the software they had
    installed. This included DAQWare (appears to be version 2.0). We thought
    we could use DAQWare to log data to a text file, which we then would import
    into the Access database. We came up with VBA code to parse the ASCII text
    file created, but have run into one problem: DAQWare does not timestamp
    each sample, but only puts a single timestamp in the header information.
    Now we could extrapolate the time for each line based on the sample rate,
    except that sometimes it seems to put in 8 values per sample, sometimes 12
    values. For instance, in the sample of a text file below, the capture was
    run for 1 minute at a sample rate of 60, and there were 480 measurements in
    the file, or 8 lines of measurements per sample. (At a sample rate of 100,
    we got 800 measurements in the file etc.) This was two weeks ago. Today,
    we returned to capture more data, and DAQWare was logging 12 measurements
    per sample (so at a sample rate of 100, we ended up with 1200 lines of
    measurements). We do not know where this factor of 8 or 12 is coming from
    or how it got changed in the two weeks between captures. We would like to
    be able to have them just run DAQWare, for days on end if they wanted,
    capture the data to file, then use our code to parse the text file into the
    database, but if we cannot put timestamps on the readings, there seems no
    point.
    *** Example of a capture below... ***
    DAQWare File
    Version: 2.0
    Number of Lines in Header: 10
    Comment:
    Date: 10-18-1999 Time: 10:01:39
    Sample Rate: 60.0
    Scan Rate: 0.0
    File Format: 1
    Samples per Channel: 480.0
    Number of Channels: 5
    O3 SO2 NOX NO2 NO
    4 3 2 1 0
    1 1 1 1 1
    0.537 0.276 0.259 -0.017 0.015
    0.537 0.273 0.261 -0.022 0.012
    0.537 0.276 0.259 -0.037 0.012
    0.537 0.276 0.264 -0.007 0.015
    *** and so on... ***
    Regarding this attempt to use DAQWare:
    1. Can you tell us where this factor (8 or 12 or however many more readings
    than we would expect) means, where it is read from or set?
    2. Is there an updated version of DAQWare that we should download that
    would be better?
    3. Is there some other existing software that we can download to use to
    perform basic logging of multichannel analog input to a text file (with
    timestamp)?
    I realise that the software comes with tools (DLL functions) that one can
    use to create custom software to interface with the DAQ board, but in the
    limited amount of time we have we are not sure we can learn enough about
    these functions to write our own datalogging software.
    However, to see if I could grasp the basics, I have looked through the
    examples for Visual Basic and think that a program would run something like
    this:
    1. at the beginning, use LPM16_Calibrate to reset the board
    2. configure acquisition with DAQ_Config
    3. start acquisition with Lab_ISCAN_Start
    4. loop to check is acquisition done with Lab_ISCAN_Check
    5. once sampling done, write data out to file
    6. loop back up to 3 to get next lot of samples
    Unfortunately, a sample app using Access and VBA I created came back with
    an error telling me it could not find nidaq.dll (even though this is in the
    Windows system directory); probably it is not a good idea to try to do this
    in Access in the first place. I am going to have a go using Delphi, which
    I know a bit better.
    One thing I am unsure of is what the numbers will be coming out of
    Lab_ISCAN; the reference file seems to indicate they will be binary
    readings, not voltages, and I wonder how to correlate these with instrument
    measurements (the instrumentation people we going to set it up so that
    1mV=1ppm).
    Any help you can give to point us in the right direction would be
    appreciated.
    Sincerely, Marc Bell ([email protected])

    I am writing regarding DAQWare, data logging software, and the PC-LPM-16
    board, which a group of us a trying to come to grips with. This is rather
    lengthy, I'm afraid...
    We are a group of college students in a computer programmer/analyst
    program. We have a course that involves doing a project to go through the
    software development lifecycle (or as much of it as can be done in a term).
    For our project we teamed up with a group in the industrial hygiene
    program; they have a computer (standalone) with a PC-LPM-16 (PnP) DAQ board
    and the NI-DAQ software (all of this has been around for a few years, but
    has not been used much), and our goal was to capture the data they are
    measuring (atmospheric pollutants) to an Microsoft Access database.
    We are not familiar with DAQ systems, but were shown the software they had
    installed. This included DAQWare (appears to be version 2.0). We thought
    we could use DAQWare to log data to a text file, which we then would import
    into the Access database. We came up with VBA code to parse the ASCII text
    file created, but have run into one problem: DAQWare does not timestamp
    each sample, but only puts a single timestamp in the header information.
    Now we could extrapolate the time for each line based on the sample rate,
    except that sometimes it seems to put in 8 values per sample, sometimes 12
    values. For instance, in the sample of a text file below, the capture was
    run for 1 minute at a sample rate of 60, and there were 480 measurements in
    the file, or 8 lines of measurements per sample. (At a sample rate of 100,
    we got 800 measurements in the file etc.) This was two weeks ago. Today,
    we returned to capture more data, and DAQWare was logging 12 measurements
    per sample (so at a sample rate of 100, we ended up with 1200 lines of
    measurements). We do not know where this factor of 8 or 12 is coming from
    or how it got changed in the two weeks between captures. We would like to
    be able to have them just run DAQWare, for days on end if they wanted,
    capture the data to file, then use our code to parse the text file into the
    database, but if we cannot put timestamps on the readings, there seems no
    point.
    *** Example of a capture below... ***
    DAQWare File
    Version: 2.0
    Number of Lines in Header: 10
    Comment:
    Date: 10-18-1999 Time: 10:01:39
    Sample Rate: 60.0
    Scan Rate: 0.0
    File Format: 1
    Samples per Channel: 480.0
    Number of Channels: 5
    O3 SO2 NOX NO2 NO
    4 3 2 1 0
    1 1 1 1 1
    0.537 0.276 0.259 -0.017 0.015
    0.537 0.273 0.261 -0.022 0.012
    0.537 0.276 0.259 -0.037 0.012
    0.537 0.276 0.264 -0.007 0.015
    *** and so on... ***
    Regarding this attempt to use DAQWare:
    1. Can you tell us where this factor (8 or 12 or however many more readings
    than we would expect) means, where it is read from or set?
    2. Is there an updated version of DAQWare that we should download that
    would be better?
    3. Is there some other existing software that we can download to use to
    perform basic logging of multichannel analog input to a text file (with
    timestamp)?
    I realise that the software comes with tools (DLL functions) that one can
    use to create custom software to interface with the DAQ board, but in the
    limited amount of time we have we are not sure we can learn enough about
    these functions to write our own datalogging software.
    However, to see if I could grasp the basics, I have looked through the
    examples for Visual Basic and think that a program would run something like
    this:
    1. at the beginning, use LPM16_Calibrate to reset the board
    2. configure acquisition with DAQ_Config
    3. start acquisition with Lab_ISCAN_Start
    4. loop to check is acquisition done with Lab_ISCAN_Check
    5. once sampling done, write data out to file
    6. loop back up to 3 to get next lot of samples
    Unfortunately, a sample app using Access and VBA I created came back with
    an error telling me it could not find nidaq.dll (even though this is in the
    Windows system directory); probably it is not a good idea to try to do this
    in Access in the first place. I am going to have a go using Delphi, which
    I know a bit better.
    One thing I am unsure of is what the numbers will be coming out of
    Lab_ISCAN; the reference file seems to indicate they will be binary
    readings, not voltages, and I wonder how to correlate these with instrument
    measurements (the instrumentation people we going to set it up so that
    1mV=1ppm).
    Any help you can give to point us in the right direction would be
    appreciated.
    Sincerely, Marc Bell ([email protected])

  • Get Total DB size , Total DB free space , Total Data & Log File Sizes and Total Data & Log File free Sizes from a list of server

    how to get SQL server Total DB size , Total DB free space , Total Data  & Log File Sizes and Total Data  & Log File free Sizes from a list of server 

    Hi Shivanq,
    To get a list of databases, their sizes and the space available in each on the local SQL instance.
    dir SQLSERVER:\SQL\localhost\default\databases | Select Name, Size, SpaceAvailable | ft -auto
    This article is also helpful for you to get DB and Log File size information:
    Checking Database Space With PowerShell
    I hope this helps.

  • Which is the best structure for start/stop data logging?

    Hi everybody,
    hope I can explain my problem good enough that anyone can help me:
    I have a VI which continuely shows on a graph the voltage of a Analog Input of a DAQ device. Now I want to allow the user to start/stop with a click on a button data logging. Means that a second loop writes to a selected path every ms the data to a spreadsheet file.
    At the moment my VI works like this:
    You run the VI and Labview asks you one time for the file path, then you can start and stop the data logging. But you can do it only one time. If you want to log a certain time later another file, you have to close and open the whole VI again which is not very professional...
    My target is:
    It is onlyl necessary to start the VI one time. Then you can select a new file path, log data, select another file path, logging data again....and so on...
    Which programm structure is necessary, can anyone help me as a labview beginner with that issue? I attached the VI if someone just wants to edit that...
    Thank you for your help!! Markus
    Attachments:
    Logging voltage.vi ‏93 KB
    screenshot.JPG ‏98 KB

    @NaruF1 and GerdW
    you are right, there is a mistake, both loop rates should be the same (10 ms) :-)
    @NaruF1
    yes you understood correctly that the file dialog should appear every time the user wants to start writing a new log-file. The voltage we measure is a analog signal, so there will be several interesting periods we want to save for a later analysis in Excel.
    To your 2nd point: if it works with a array it will be fine. But it must be possible to log data for lets say 5 minutes, so the array won´t be too large? (5 min @ 10  ms loop rate will be 30000 rows..
    attached is the VI, saved as LV2009..
    Thanx a lot!
    @GerdW
    ..you ask why I didn´t create a structure like you recommended with notifiers or queues? The simple answer would be that I am not familiar with all this.. just began to write my first Labview programm. I will have al look to the LV help with all that stuff... Thank you a lot
    Attachments:
    Logging voltage.vi ‏80 KB

  • Multithrea​ding and RS232 data too slow processed

    Hello,
    Hope someone could help with this issue.  I have simple application which process ASCII data coma separated from serial port at speed of 115.2kbps. There is 6 columns  of unsigned short data .  I set-up COM call back function to receive data and I created separate thread function to plot data  on a 6 graphs - PlotWaveform() used.  Plots roll-over from beginning every time it receives more then 3000 samples. There is couple of more command buttons to set-up serial port, save data to a file, and exit application.
    What is problem?  Application runs as intended but more and more slow with each received data sample. It is visible how graph plotting slows down. Apart from this,  all command buttons do not respond on cliks. (I need to click few minutes on them to get attention.)
    Thanks
    Solved!
    Go to Solution.

    Thanks Roberto,
    a) I continiously receive RS232 data from external device without request. I install  COM callback func.
    InstallComCallback (comport, eventMask, notifyCount,eventChar, ComCallback, NULL);  where is:
    static int eventChar =13;   
    static int notifyCount =115;
    Call back functions where I process data and store them into 6 arrays of 3000 elements:
    void CVICALLBACK ComCallback(int portNo, int eventMask,void *datax);
    b)  I assume ComCallback is called every notifyCount samples.
    c)  Second thread what I installed plots only 6 received data arrays in the ComCallback(). 
    static int CVICALLBACK PlotingThreadFunc (void *functionData)
      while(1)
                      if(plotFLAG == TRUE)
                                        plotFLAG = FALSE;
                                        //Plot Array1
                                        PlotWaveform (panelHandle, PANEL_GRAPH, CapMeasureArrayData1,
                                                      ​                                          u16_DataIndexC, VAL_UNSIGNED_SHORT_INTEGER, 1.0, 0.0,
                                                      ​                                          0.0, 1.0, VAL_FAT_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1,
                                                      ​                                          VAL_RED);
                                             to ..........
                                        //Plot Array6
                                        PlotWaveform (panelHandle, PANEL_GRAPH_CAP6,
                                                      ​                                          CapMeasureArrayData6, u16_DataIndexT,
                                                      ​                                          VAL_UNSIGNED_SHORT_INTEGER, 1.0, 0.0, 0.0, 1.0,
                                                      ​                                          VAL_FAT_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1,
                                                      ​                                          VAL_RED);
     return 0;
    The plotFLAG is set in the ComCallback() when data is received.
    d)  I plot as above, whoole data arrays when data is received.
    e)  “Plots Roll-Over”  I meant: Plots are window into data steram and when it is plotted max. number of elements (3000) then arrays are erased and start new data plot from beginning.

  • Data logging optimization function in LabVIEW and SignalExpress

    Hello, everyone!  I and a colleague have assembled the attached VI,
    which is used to control a plant growth chamber, and I could use some advice. 
    I would like to add data logging capabilities, ideally to note (1)
    environmental conditions, such as temp and CO2 level and (2) when certain
    situations occur, such as high CO2 or low pressure (which results in a change
    to the “Case Structure for CO2 and Pressure”).
    The chamber runs for weeks at a time, though, so I have a constraint.
    Instead of continuously logging all the environmental data (which would yield
    giant file sizes), I want to be able to take “snapshots”, say every 5 minutes,
    so I can examine the chamber’s condition over a long period of time.
    I attempted to use the Time Delay function to control the Write Measurements
    function (as in LabVIEW’s Cycle Analysis example, which I’ve also attached),
    but Time Delay halted my entire program. 
    I also tried the Wait (ms) function, but had no success.
    I recently discovered the powerful data review and reporting tools that
    SignalExpress has to offer.  Ideally, I
    would like to use a SignalExpress express VI to record the measurements instead of the more primative Write Measurements, but, I’m not sure how to implement this in my VI.  For example, would I make a data acquisition VI in SignalExpress for all my sensors, export to LabVIEW, and use that to replace the current DAQ structure in my VI?  (Because the chamber VI is interactive, I'm pretty sure that porting the LabVIEW VI to SignalExpress wouldn't work out well.)  And I’m
    still not sure how to control how often it records measurements.
    Any advice would be much appreciated!
    Attachments:
    Chamber VI.vi ‏789 KB
    Cycle Analysis.vi ‏300 KB

    Hi, Sarah.  Yes I definitely plan to use LabVIEW for the majority of my data acquisition and logging.  I apologize, I think I probably should have broken my post into two separate posts for clarity, as my major concern is being able to set how often LabVIEW logs the environmental data (viewing the logged data in SignalExpress would be nice, but not a requirement).
    As I explained before, I'd really like to be able to set up a system that records the environmental condtions at regular time intervals, say every 30 minutes, or if my "Case Structure for CO2 and Pressure" status changes (such as from "Normal Conditions" to "High CO2".
    As an example, attached is a boolean structure (TimedWritedMeasurements.vi) that I came up with to record a simulated signal every 5 seconds (5000 ms).  Once I can get it to work, I would connect the boolean to my environmental sensor outputs and CO2 and Pressure case structure in my Chamber VI.vi that I attached in my first post.
    My problem is I can't seem to get the Trigger and Gate function to work the way I'd like.  I'd like the Wait (ms) function to trigger the Trigger and Gate function every 5 seconds to change the case structure in the TimedWriteMeasurements.vi to "True", thereby causing the Write Measurement function to record the environmental conditions.  Then I'd like the case structure reset to false, until it's triggered to true in another five seconds.  Can anyone point me in the right direction?
    Attachments:
    TimedWriteMeasurements.vi ‏84 KB

  • Belle: No WLAN and Packet Data log.Filter options ...

    In Nokia N8, with Symbian Anna, WLAN and Packet Data logging wasn't possible, even though there were options in the log filtering settings.
    See below:
    http://i44.tinypic.com/9kxbfa.png
    After updating to Belle, log isn't still working, and both WLAN and Packet Data options were removed from filter options.
    http://tinypic.com/r/6dxwgg/5
    Will it be implemented in a further time?
    Best Regards

    Hi,
    quick update on this one as we now have a FAQ online.
    Q: How can I get a WLAN/Wifi and packet data filter with Nokia Belle?
    A: There is no data filter included in Nokia Belle by default, but you can download specific apps from Nokia Store.
    BR,
    yvonne

  • Data Logging a programmatically created shared variable of cluster or array datatype into citadel DB

    Hi,
    Is there a way to log a programmatically created shared variable of cluster or array datatype into citadel DB?
    I have attempted to programmatically create a shared variable of type 'double' and was able to successfully log the same into Citadel DB. In the attachment, Please refer to the attached project SV_TC.lvproj and specifically to SV_W.vi for the code that i have used (W.png file shows the dB in MAX and shared variable in NI Distributed System Manager)
    However when i tried the same approach to create a shared variable 'array of double', i noticed that traces are not getting created and hence data logging isn't happening into the Citadel DB. I was however able to write and read the shared variable array without issues. The same is true with cluster datatype also. Please refer to SN_NW.vi for the code that i have used - only difference from SV_W.vi is that i have tried to create a shared variable of type 'array of double'
    One observation is that if i create an 'array of double' or cluster in a shared variable library using the project explorer and deploy, i could see that these being logged into Citadel DB.
    Hence i want to understand what could be done to achieve the same programmatically? Could you please advice?
    Regards,
    Sridhar
    Attachments:
    SV_TC.zip ‏3925 KB

    Why is the transaction happening over remote?
    Because we need the information to be on our database immediately when they submit it.
    I don't know anything about streams or replication.....
    The web database is run by the company that hosts our web site. We use PL/SQL to show the pages and output the html. It fetches the data the customer is requesting from our database, but I'm struggling to get the best way to insert into our database from there.

  • Most efficient way to constantly read, queue and parse multi-size​d RS232 data (multi-thr​eaded)

    I've tried tackling this problem a few different ways, and figured it was time to get some others' advice.  My system essentially works, although it looks like a hackjob and not entirely confident.
    My RS-232 connection has the following properties/constraints:
    -Will be getting unsolicited data at a high data rate.  (ya thats subjective, but assume near constant at whatever baud rate its set at up to 115200)
    -Different segment lengths of data receiving
    -Two stop bytes (0x10 0x03), while start byte is 0x10.  (Byte stuffing/packing implemented)
    -There is a size byte within a packet (3rd one in), however currently relying on stop bytes only.
    I have tried the ComCallback within CVI only to find that it is VERY slow at processing events compared to implementing it manually in its own thread.  In addition, it can only trigger 1 stop bit, not 2.  Triggering on size is sometimes okay, but I found that it was possible it would get triggered on only part of the data, the when its called the qlength be larger, and then sometimes I would only read part of a data packet, and half of my segment was still in the queue.  And sometimes, I would get semaphore locks and lots of waiting, and ya it was a mess (hence you will see lots of CMT locks commented out)
    I tried implementing a FIFO type queue (copied below), but I have very little experience in doing this, and may not be very efficient in the way I implemented and could definately use some advice in this area.  Also perhaps in how thread safe I have everything.
    I thought about a circular buffer, but since data can be different segment lengths, it kind of makes it difficult to cleanly wrap around and read.  I think its still possible, just may require additional checks which I haven't seen done anywhere when google searching. (and made me think a FIFO queue was better).
    So if anyone has any good suggestions or examples, that would be great.  Using Labwindows 2010.
    //in Main before GUI loaded
    programRunning = 1;
    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, ComCallback, NULL, &funcID);
    /* Function Used to parse Com data */
    static int ComCallback (void *callbackData)
    static int bufLen = 0;
    int strLen,qLen=0;
    unsigned char tempBuf[1024];
    int packet_length = 0;
    char temp_string[250];
    unsigned char *start_ptr;
    int i;
    int start_offset;
    while(programRunning) {
    //First lets copy all data from com port to output buffer
    if( com_open) qLen = GetInQLen (comPort);
    if( qLen <= 0 ) {
    ProcessSystemEvents();
    } else {
    if( qLen > 1024) qLen = 1024-bufLen; //set max length to read
    strLen = ComRd (comPort, tempBuf, qLen);
    //CmtGetLock(lock);
    memcpy(readBuf+bufLen,tempBuf,strLen);
    bufLen += strLen;
    //CmtReleaseLock(lock);
    //Try to read until we hit stop bytes, or until we think we have at least 1 or 2 packets to process
    if(tempBuf[strLen-2] != 0x10 && tempBuf[strLen-1] != 0x03 && bufLen < 100 ) )
    goto skip;
    //ensure start pointer is at beginning command (0x10 0xAA) (in event we just started reading in middle of packet???)
    i = 0;
    while ( (readBuf[i] != 0x10) && (readBuf[i+1] != 0xAA) && (i < strLen) )
    //start_ptr++;
    i++;
    start_offset = i;
    parse_some_more:
    start_ptr = readBuf + start_offset;
    //lets try to do one packet at a time.
    for(i = start_offset; i < bufLen-start_offset-1; i++)
    if(readBuf[i] == 0x10)
    if(readBuf[i+1] == 0x03)
    i += 2;
    break;
    //trial of unpacking/unstuffing byte buffer
    else if( readBuf[i+1] == 0x10 ) //two tens in a row, remove it
    memmove( &readBuf[i],&readBuf[i+1],bufLen-i);
    bufLen--;
    //at this point, we should have a full packet. What if we don't....???
    packet_length = i - start_offset;
    //CmtGetLock(lock);
    ParseResponse(start_ptr,packet_length);
    PostPacketToOutputBuffer(start_ptr,packet_length);
    if(start_ptr[start_offset] == 0x10 && start_ptr[start_offset+1] == 0xAA )
    com_Send_Acknowledge(comPort);
    start_offset = packet_length + start_offset;
    if(start_offset < bufLen-1)
    goto parse_some_more;
    //For now, assume everything else we don't care about in buffer, however, probably shouldn't. Should it be bufLen -=start_offset; if so, need to handle partial data better; timeout??
    bufLen = 0;
    //CmtReleaseLock(lock);
    skip:
    return 0;
    Thanks!

    Hi ngay528,
    I think there is a great example for you to use that comes with CVI which can be found by clicking Find Examples on the splash screen or Help >> Find Examples in your project. From there, click into Optimizing Applications >> Multithreading. In that folder there is a project that is called BuffNoDataLoss that shows how to create a thread safe queue and setup a producer/consumer type program. In this example the data is a random sine wave but could be adapted to your RS232 data. If you have any questions concerning this example please let me know but this should be a great starting point.
    Patrick H | National Instruments | Software Engineer

  • Help In keithley 2400 VI!!(Problem with the data logging and graph plotting)

    Hi,need help badly=(.
    My program works fine when i run it,and tested it out with a simple diode.The expected start current steps up nicely to the stop current.The only problem is when it ends,i cannot get the data log and the graph,though i already have write code for it.Can someone help me see what's wrong with the code?I've attached the necessary file below,and i'm working with Labview 7.1.
    Thanks in advance!!!
    Attachments:
    24xx Swp-I Meas-V gpib.llb ‏687 KB

    Good morning,
    Without the instrument it might be hard for others to help
    troubleshoot the problem.  Was there a
    specific LabVIEW programming question you had, are you having problems with the
    instrument communication, are there errors? 
    I’d like to help, but could you provide some more specific information
    on what problems you are encountering, and maybe accompany that with a simple
    example which demonstrates the behavior? 
    In general we don’t we will be unable to open specific code and debug,
    but I’d be happy to help with specific questions. 
    I did notice, though, that in your logging VI you have at
    least one section of code which appears to not do anything.  It could be that a small section of code, or
    a wire was removed and the data is not being updated correctly (see pic below).  Is your file being opened properly?  Is the data being passed to the file
    properly?  What are some of the things
    you have examined so far?
    Sorry I could not provide the ‘fix’, but I’m confident that
    we can help.  Thanks for posting, and
    have a great day-
    Message Edited by Travis M. on 07-11-2006 08:51 AM
    Travis M
    LabVIEW R&D
    National Instruments
    Attachments:
    untitled.JPG ‏88 KB

  • Clarification on packet data log

    I understand the Packet Data logs can remember upto last 30 days. What I don't
    understand is are they rotating logs or do they reset to zero every 30 days. To take
    an example: if I use exactly 1MB every day and my log setting is set to 30 days. After
    40 days ...
    - with rotating logs, I'll see 30 MB usage
    - with reset-to-zero logs, I'll see 10 MB usage
    So which one is it ? I'm using C5-00 on 032.010 if that matters. Thanks.

    k

Maybe you are looking for

  • ALV Report Print Problem.

    Hi, When I Print any ALV Report then In the First Row BackColor is white, but in Second it is Gray,and this alternative for all remaining rows, How Can I SET it to White For ALL Rows. Thx, Hitesh Jain.

  • How "not to set locale " in user's profile?

    In the "Oracle Universal Content Management 11gR1 Differences between 11gR1 and 10gR3" document http://www.oracle.com/technology/products/content-management/ucm/diffsbetween10gand11g.pdf says: "If locale is not set in a user's profile, Content Server

  • Problems with Image Field Table in Adobe Forms

    Hello, I have a desgined a Adobe Form(Print Only) in the Adobe Desinger in NWDS. The form layout contains a table of images in 2 columns and 3 rows. Every Column has a Image Field and a TextField displaying the Image URL. The URL of this image is pas

  • Do all updates need to be applied in order?

    Or does the last update contain everything in the earlier patches? I just recently installed ID CS4, and haven't had much chance to work with it. However, I think I only applied two of the six or so updates available for it, including the last one. I

  • How to solve repeated Bugcheck. The bugcheck was: 0x000000d1 (0x0000000000000010, 0x0000000000000002, 0x0000000000000000, 0xfffff8016a71d56c).

    Log Name:      System Source:        Microsoft-Windows-WER-SystemErrorReporting Date:          6/25/2014 08:09:27 Event ID:      1001 Task Category: None Level:         Error Keywords:      Classic User:          N/A Description: The computer has reb