RS-232 different speed on console vs window

I have a simple application that I made to test the flow of data from a device.  I had trouble with slow communications with another program, so I wrote this one to test only RS-232 communications. My problem is that I get the result differs depending on whether I have compiling the program as a console application or a windowed application.

My device sends packets of 70 bytes message at 100 Hz using 460800 baud, 8-N-1.  I use a USB adapter for series, which is supposed to support the baud rate.  Using the console application, I get about 7 000 bytes per second, which is what I expect.  However, when you run a windowed application, I get about 34 bytes/second.  Anyone got any ideas on why there is such a big difference?  (CVI 2013 on Win7)

Code is below.  I use the inputs are: [COM port number], 460800, 1.



int main)
{
FILE * outFile;
FILE * binFile;
int iNumBytes = 0;
char cMessageArray [720];
Secret int;
int iPortNum;
long lBaud;
int iByteRead;
int iGetRate;
char cFileName [20];
time_t timeStart;
time_t timeStop;
long lByteCount = 0;
long lTimeoutCount = 0;
long lNumSeconds = 0;

printf ("recorder Port. ") \nWrites bytes received on the port selected in a file ({Port #} .txt) .\n\nEnter COM port: ");"
scanf ("%i", & iPortNum);
printf ("\nEnter baud rate:" "");
scanf ("%u", & lBaud);
printf ("\nEnter 1 just calculate the byte rate:" "");
scanf ("%i", & iGetRate);

printf ("\nListening on the port %i to baud rate %i (8-N-1) w/half second timeout. ") Press any key to stop. \n", iPortNum, lBaud);

DisableBreakOnLibraryErrors();

Secret = OpenComConfig (iPortNum, "", lBaud, 0, 1, 8, 8192, 1024);
SetComTime (iPortNum, 0.5); COM read the time-out in seconds

<= istatus="">
{
Open output files
sprintf ('% u.txt', cFileName, iPortNum);
outFile = fopen (cFileName, 'wt');
sprintf ('% u.bin', cFileName, iPortNum);
binFile = fopen (cFileName, "wb");

time (& timeStart);

If (1! = iGetRate)
{
While (!.) KeyHit())
{
iByteRead = ComRdByte (iPortNum);

If (-99! = iByteRead) / / IF not a timeout
{
iByteRead = iByteRead & 0x00FF;
fprintf (outFile, "%.2X", iByteRead);
printf ("%.2X", iByteRead);
cMessageArray [iNumBytes] = (char) (iByteRead & 0x00FF);
iNumBytes ++;
lByteCount ++;

If (70 is iNumBytes)
{
fwrite (cMessageArray, 1, 70, binFile);
iNumBytes = 0;
printf ("\n");
}
}
on the other
{
fprintf (outFile, 'TIMEOUT');
printf ("TIMEOUT");
lTimeoutCount ++;
}
}
}
on the other
{
While (!.) KeyHit())
{
iByteRead = ComRdByte (iPortNum);

If (-99! = iByteRead) / / IF not a timeout
{
lByteCount ++;
}
on the other
{
lTimeoutCount ++;
}
}
}

time (& timeStop);
lNumSeconds = timeStop - timeStart;

printf ("bytes = %i seconds = %i bytes/s = %f\nTimeouts = %i\n", lByteCount, lNumSeconds, (float) ((float) lByteCount / (float) lNumSeconds), lTimeoutCount);

fflush (outFile);
fclose (outFile);
CloseCom (iPortNum);
}
on the other
{
printf ("cannot open the COM port.");
}

printf ("\nPress any key to close. \n ») ;

GetKey();

While (!.) KeyHit())
{}

return 0;
}

Thank you!

Your program GUI can be affected by the CVI political intelligence defined in the environment options.

I seem to remember that the value default for this setting is to sleep more, which means THAT CVI give much time to the operating system to serve other tasks or programs. You can try with some sleep or not sleep; in the latter case, don't forget to insert some ProcessSystemEvents somewhere in your application to allow to honor events of UI in the case otherwise you will not be able to exit the loop.

The same option can be set programmatically by calling SetSleepPolicy)

Tags: NI Software

Similar Questions

  • Whenever I play youtube videos, they shake from left to right and to go at different speeds.

    I have windows 7. A couple of days, I went to play youtube videos and they all shake from left to right and go at different speeds (very erratic). This ONLY happens with videos from youtube (HTML5). When I play other videos(non-HTML5), they play very well. Also, the sound on youtube videos are fine, only they do not match the mouth (s) of people talking. The mouth move faster. I've checked all my plug-ins and everything is up-to-date. My firefox browser is also the last version. I did a malwarebytes scan and it came up with nothing. All the settings on the youtube videos are also where they should be. It happened for about 5 days. Can someone help me?

    Thanks Guigs. I followed your instructions and found out it was a 'acceleration hardware problem' that was the origin of the problem. I unchecked the box and YouTube videos play very well! Thank you for taking the time to help me.

  • The scanned Pages of ADF not readable-pulls sheets with different speeds &amp; streaks page...?

    I have a HP Officejet Pro 8500 has more who struggled to properly perform the analyses of the ADF.  It seems that is happening WITH PDF FILES.  The ADF will get out the paper at different speeds, creating the effect below.  When it goes faster (you can hear it speed up), you get the lines; When he finds the right speed, you get what is digitization of bottom-good copy.  It seems to work correctly in photo mode, etc. - ONLY WITH PDFS.  Sometimes, it can properly analyze dozens of pages (and did very well in the past), and now he has started to do this.

    I cleaned the rollers, but appear not to be the problem if it happens only with PDFs.  I cleaned the glass of 1 inch Strip, but would not be the problem either if the bottom of the page (or top or wherever it happens to go faster) has NO scratches on it).  I have looked at post after post and cannot understand it.  What could be wrong! ???

    BTW, I have a Windows 7 64 bit computer that I use with it.

    Thanks for any help!

    I'm glad to hear your good news, and I appreciate the update.  This could be valuable information for someone else.

    I'll give you a link which deals with topics of the ADF.  Click here  This will show you all the ADF areas that need to be cleaned.  A wet coffee filter is a good tool for the cleaning of the rollers.  Alcohol friction broken residue sliding in this situation, but for a regular cleaning, I would recommend distilled, filtered or bottled water.  Nice day!

  • Impossible to get Speed Carbon running on Windows 7

    I need speed carbon and running windows 7, the game becomes ea Announces and then it just goes back to my desktop any ideas?

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

  • Switched Port Analyzer (SPAN) with ports different speed

    Hi all

    I want to configure the Analyzer SPAN (Switched Port) on 6500 SW as TenGig port Source port and destination port that connects the device is 1 Gig. This works if the source and destination have different speeds?

    Kind regards

    Lou.

    Then your ok so its only 500 MB, its more subscription simply monitor on the duration of

  • How to change the speed of playback on Windows Media player?

    Original title: slow down the Windows Media feature?

    Is there a slowdown function to allow me to slow down or speed up a song?  I use Windows 8

    Hi Andy,.
     

    Welcome to the Microsoft community.

     
    I would like to give you some information:

     
    You want to adjust the speed of playback of multimedia content on Windows Media player?

     
    If you try to adjust the speed of playback on Windows Media player, you can follow the steps:

     
    (a) click on Switch button playing in the lower right of the player.
    (b) right click on a space open in the player (such as to the left of the stop button), point to enhancements, and then click play speed settings.
    (c) move the speed slider to play at the speed that you want to read the file, or click the slow, normal or fast links.
    It will be useful.

     
    Let us know if you need help on issues related to Windows.
  • vibration of different speed variators breaking raid

    I want to set up a SAN for my system of vsphere server, using a combination of different speed variators and have several bays. I would so a raid 1 of 2 7200 RPM drives and a 1 2 10 K rpm disks. I heard that have a mix of different drive speeds in the same physical box may break tables because the vibrations caused by the reader different speeds live upward the read/write heads in readers. Is this true? Also, I heard say that while it is true that you can do it too long the chassis supports in particular the use of the different speeds in car inside.

    Anything done by a well known manufacturer of server will be fine.   HP, Dell, Sun, SuperMicro is all considered this.

  • Created a slide show time with a different speed than the speed for which it has been created in Windows MEdia Center

    HELP PLEASE! 1

    I create a slide show with music in Windows Media Center.

    I have change in SETTINGS, the display time of 3 seconds.

    I have burn the slide show with music on a DVD.

    The copy on DVD playing 7 second display speed.

    I want to play as I created it, to fit the music.

    HOW?

    Thank you

    Rhod

    Sydney Australia

    Use the creator of Windows DVD or Windows Movie Maker (new versions available here) to refine your settings.

  • Upgrading my cpu speed zip files in Windows 7

    I currently have an i3-2100 (Socket 1155).  I compress TIFF files (137 MB each) in records of 15 or more.  It takes forever.  I checked my use of RAM and it runs around 37% while the zip compression and listen to trance music streaming from Youtube at the same time (from 4 MB of RAM installed) to get more RAM doesn't seem to be the solution.

    Would a processor "more powerful" speed things, hopefully much (stay with Socket 1155)?  Or is program of internal compression of W7 (what I want to continue to use it as people who receive my files zipped using Windows Explorer to decompress files) just by nature dog slow and isn't really dependent on cpu?  You know, it is what it is.

    So far no response.  If anyone has a suggestion for another forum post this question please let me know.

    Asked me to come back and "finish my thread.  Well, no answers here, so I asked on a photography forum and it has been suggested, I have try 7 - Zip.  This free program, in fact, compressed files JPEG and TIFF in about 1/20th, time to spend it as a Windows Flash program to accomplish its task.

    I also learned that seamer works better on text files and not so much on image files.  Indeed, a compressed jpeg file is about the same size as the original file.  A compressed tiff file password 137 mb 125 MB so some, but not much.  Why it takes so darn long comes mainly from transfer images JPEG in a different folder Windows is beyond me.  I assume that 7-Zip goes account that it does nothing more than to transfer them on and done it gets about as fast I could rename the original folder.

    Minimally, TIFF, 7-Zip compresses and gets it done almost immediately.  Windows takes 30 minutes or more.

    Discussion was going and came on whether or not would help more RAM.  The consensus is that it is not useful.  What helped was to use 7 - Zip.

    I also tried to pass like a Flash on a different computer on W7, I (an older i5 which has a four true cores) and it was slower in the Windows program as this computer.  This computer has an i3-2100, but has hyperthreading.  Given that 7-Zip can use hyperthreading maybe thats why it is so much faster.  Who knows.

  • Slow download speed after downgrading to Windows 7 64 bit

    Hi all!

    I'm new here! My first laptop is a Toshiba Satellite since 2003. Since then, I got one couple of others.
    Now I bought a new: Satellite P70-A-11V, a portable professional high-end computer, which came with Windows 8, which I upgraded to 8.1.

    Unfortunately, the degraded system so bad that all pendrives made plant. I have connected my Toshiba camcorder, and it also crashed the laptop. The search indexing was not working outside the C: drive. The pointer of an optical mouse has started to freeze for seconds on the screen.

    This last problem, which I think was due to the low power USB ports. So, I really had no choice after 2 restorations system total and installed Windows 7 Enterprise x 64 SP1. The operating system seems ok, but I always have problems, and one of them is that my download speed is very low, as well with LAN cable or wireless. I can't tell how is download speed.

    My internet provider provides 100 MB/s internet access via optical cable. I test on Speedtest.net and normally, it gives a range of 50 to 80 Mbps actual download speed. Then, if I check the speed of the connection Wireless wireless connection status, I experience a maximum of 130 MB/s, which is constant. Large.
    Yet, no download occurs at a speed of wretched 400 to 500 kbit/s, as if it was a dial-up connection. This problem was not present before.

    I tried to change several settings according to the forums, but nothing helped. I disabled the firewall and stimulated wireless (duplex 100 MB) and also tried through LAN cable. The rated speed is great, but apparently the slowness problem is inside the laptop, not outside. Any ideas will be greatly appreciated!

    I checked the Toshiba download page and your laptop is fully supported for Win7 64 bit. Drivers LAN and WLAN are available also so I hope that you have installed all the drivers, tools, and utilities including LAN and WLAN. Can you confirm this?

  • Finished samples timed material vs single-point: different speed?

    Hi all

    Although I had several questions about this request before that separately have been resolved, there is one last thing that remains difficult.

    Shortly:

    My application acquires data from 2 analog and synchronous inputs on 2 channels of analog output.

    There is a trigger stop set on a PFI-pipe with a single switch. To make of this

    I had to switch from single-point over acquition timed work material.

    This set works very well when I read not less then a 100 samples once with a sampling of 1000 Hz. frequency (when I go below a sample of 100 to read--> E-200279)

    Ideally, I would like to read about 10 samples with a sampling frequency of 1000 Hz.

    However, using single-point timed equipment acquisition I can easily do that without a problem. Even just reading

    a single sample once with a sampling frequency of 1000 Hz does not have a problem. But impossible to use the block of relaxation of reference as a signal to stop with this setting!

    Question:

    For me, there are two solutions, but so far I could not work on one of them:

    (1) build a stop trigger in an single point of timed material acquisition

    (2) change something in the acquisition of finished so that I can read faster.

    Any suggestions, what causes the difference between the two speeds to be able to read the data and a way to solve it?

    Thank you

    Mark

    Mark,

    I mocked how I think I would like to address the issue and tied it to the top.  The general idea is that we use HWTSP for our analog I/o and counter looking edges on our signal "stop".  Each iteration of the loop, we check if we saw the stop signal.  If we have, then we write zero for the output channels and stop the loop.  If this isn't the case, write us the data of your comments, we have calculated.  I've added some comments on the block diagram that I hope are useful.  I have currently no any material of series E share, so it may not work properly out of the box, but I thought it would point you in the right direction.

    I offer this precaution:

    Windows is not a real-time operating system.  Therefore, it may take the liberty to give as much CPU time to other processes or applications as he likes.  As a result, it is likely that you will not miss a few samples (IE, your loop will not go faster hardware issues are examples of clock).  I configured DAQmx must return a warning you when this happens.

    Hope that helps,

    Dan

  • The console of Windows Server Update Services (WSUS) falls down when you search for updates and displays the following error message:

    An unexpected error has occurred.
    Click the node server reset to try to connect to the server again

    Event type: error
    Event source: Windows Server Update Services
    Event category: no
    Event ID: 7053
    Date:
    Time:
    User: n/a
    Computer:
    Description: The WSUS administration console has encountered an unexpected error. Maybe it's a transient error; try to restart the administration console.
    Cause
    This can happen if the application cache is damaged.

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • the console application window brings forward on printf

    Hello, this is the first time with LabWindows CVI (version 9) and I noticed on all the 'printf' console is presented in the foreground. It is therefore impossible to use the computer during my tests that print report in the console. Minimizing the console does not help, it is leading. Piping the output to a file, while no output on the console, always brings the console window to the foreground on each printf.

    Any way to disable this feature, so it behaves like normal console programs?

    Thank you

    Jason.

    You can use the SetStdioWindowOptions() function, passing 0 as the second parameter to correct this problem. (this default setting was also irritates me for some time).

  • my broadband speed is lagging on Windows but is normal in safe mode. Why?

    my broadband has to operate at 50 m, but I get only 25 m in normal mode, but when I do a test in safe mode with network I have complete 5 m can you tell me why and there at - it anytyhing I change mode normal mode to fix this

    Hello

    1. you got speed broadband before without any problem?

    2. did you of recent changes on the system?

    3 Windows operating system you are using?

    Method 1:

    As the bandwidth works correctly in safe mode with networking, you can try to perform a clean boot and check if it helps.

    A clean boot to check if startup item or services to third-party application is causing this issue.

    You can read the following article to put the computer in a clean boot:

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    Note: After troubleshooting, be sure to set the computer to start as usual as mentioned in step 7 in the above article.

    Method 2:

    You can temporarily disable the third-party antivirus and firewall installed on the computer and try to install the drivers and see if that fixes the problem.

    If disabling the antivirus software solves the problem, you may need to configure the settings of the antivirus as a result program. Please contact the software vendor for assistance in this regard.

    Note: Make sure that you enable the antivirus software, other security and firewall after the test programs.

  • Internet high speed decreased after installing Windows 8.1

    Dear guys, I installed Windows 8.1 on my laptop HP Pavilion G6 2241sa.

    Everything is perfect, I downloaded all the drivers, internet works fine BUT I noticed that the speed of my broadband a few minutes down from 80%. My broadband speed is 30meg to bottom/30 megs.

    Download speed is reduced to 2-3megs, but upload speed remains the same...

    My Network (displayed in the Device Manager) card is AR9485 of Qualcom Atheros 802.11b/g/n wifi adapter.

    When I uninstall, Windows automatically detects and installs back. Internet high speed returns to normal, but after a few minutes or maybe 10 12 minutes speed drops back down, until the speed remains unchanged... I removed it 10 times, even tried to reinstall all the ralink drivers for win 8 or Win8.1, but Windows says I have the perfect driver and that it does not install anything else. I removed just in case antivirus, does not work. I checked the speed on the other computer - no problem there, but on my laptop it persists. On Windows 7, I didn't have this problem, it started after Win 8.1.   If you could please help me fix. Thank you very much. Lives

    OK, this is my last post on this topic because I think I solved the problem.

    I thought it was Windows 8.1 to blame, but I finally installed Windows 7. Internet was excellent, but after I installed all the latest drivers of the site Web of AMD (Amd catalyst, video driver, etc.), down speed was limited to 2 to 2.5 Mbps.

    I used the system restore and Internet working again. I decided to check again, and after that I installed again the pile of last softward to Amd, I had problem once again. Prolem is therefore up to the latest version of the AMD software. Do not know exacctly what part, perhaps things like AMD stream or similar. I also believe that this issue includes my modem that does not like to communicate with my computer that has these last things AMD.

    Anyway, thanks for reading. My internet gives me full speed and I am happy with that. I just create a system restore point before updating to new drivers from the site Web of AMD. It's easy to go back. A big thanks to everyone! Lives

Maybe you are looking for