|
The fundamental purpose is to capture telemetry data, all numbers, reformat them, and send them to another computer.
HOWEVER: as often needed, I need insight into the application. Keeping this short: An MFC is used and sometimes an AFXMsgBox window is needed to inform the user of errors detected. There is also a log file. It needs to be read to see how the program operated.
Does that help narrow the field?
Edit:
I read that I really should switch to Unicode, so I did and started using WCHAR. Now I discovered that it is just a retype of wchar_t, and further that it is Microsoft unique. I do not expect to write code that can be dropped into a Unix machine and compiled, but would like to be reasonably compatible. So what the heck should be used?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 13-Jun-14 16:27pm.
|
|
|
|
|
bkelly13 wrote: Does that help narrow the field? Not really, since all of those issues may be handled in ASCII or Unicode without any problems. You omitted to explain the format of the input data: numbers as in characters (ASCII or Unicode), or numbers as in binary values? And, if the latter what do you convert them into (if anything).
If you are using Unicode for all your text then stick with WCHAR, since it's a macro and can be defined to equate to any native unicode type on other platforms.
|
|
|
|
|
The data is received as binary values and is signed, unsigned, with sizes from 1 bit per parameter to 32 bits. Some value are floating point number. All binary format, no text in any form. My application picks them out of the stream, shifts them into the correct position, applies scale and offset, assigns identifying tag numbers, and TCP the data out to a display device.
The text is used to create a configuration file for each of the different telemetry types. That is done with VBA for Excel that I write. Log files that show performance are in a text format that are read with Microsoft Wordpad. The startup configuration work and the performance monitoring use text. All the primary operations are shuffling binary data around and do not use any text.
Your comment that WCHAR can be redefined to something else for another device was a revelation. Simple and obvious and completely missed. It makes a rather big difference. Thank you for the idea.
I was thinking of std::string. Do you think that would be a valid choice? Because of your comment it is not as likely, but I would like to hear you thoughts on that anyway.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: I was thinking of std::string That would also be a valid choice, although be aware that std::string is ASCII only, for Unicode you need to use std::wstring . I tend to use a typedef to define my own type which will be ASCII or Unicode, dependiing on the project settings. Something like:
#if defined(UNICODE)
typedef std::wstring STRING;
#else
typedef std::string STRING;
#endif
Then I just use STRING everywhere in the rest of the code, and the compiler sorts it out for me.
From your comments above and the description of what your code is required to do, it seems that the choice is far less important than your first message implied.
|
|
|
|
|
Re: well, yes and no. It is less important on this particular project. It is more important in that as I become used to one type or the other I will tend to use it on subsequent projects.
Not very many people/places are heavy into telemetry and some of those are unix/linix shops. WCHAR is fine, but I am thinking that std::wstring might be the better option. The TCP/IP will make it difficult to port, but I can do little about that. (Well, not true, but out of scope.)
Thank you for taking the time to reply.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: The TCP/IP will make it difficult to port If you stick to the basic TCP/IP functions (connect , listen , send , recv ) it will port with no problems.
|
|
|
|
|
I am writing this to use non-blocking and overlapped with events to signify I/O completion. The WSA* calls are used. Does that reduce portability?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
Yes, WSA functions are all Windows sockets, so not directly portable. Although you could always write some code of your own to cater for that if necessary.
|
|
|
|
|
Sometimes you need both.
For UTF-8 unicode I use std::string
For UTF-16 unicode I use std::wstring
|
|
|
|
|
Widows 7, Visual Studio 2008, C++, socket operations
My app posts a listen using a socket set to non-blocking. The debugger steps over that line, with a noticeable pause, and continues. The netstat command showed that a listen was in progress.
I can think of a few possibilities to end the listen().
1. Client connects
2. Call some method to terminate the listen.
3. Delete the object that initiated the listen
If the client does not connect, how should the app close the listen() operation?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
Typically in Windows just closing the socket causes the listen to terminate.
|
|
|
|
|
I will do it that way. Thank you.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
Windows 7, Visual Studio 2008, MFC, C++
A thread is started when a dialog button is clicked. The thread performs some tasks than sets event 100, an arbitrary number for conversation. The dialog is to detect that event and display some text without user intervention. What can be done in the dialog to accomplish this?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
It would be a better idea to use the proper Windows mechanisms. When the thread has completed its task it should send a message to the dialog.
|
|
|
|
|
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development.
Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: an environment with no window and will set several events Without knowing how and where it sets these events it's difficult to suggest anything else. However, you may like to look into the various IPC mechanisms[^].
|
|
|
|
|
Hi,
bkelly13 wrote: Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.
Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^]
Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads.
Best Wishes,
-David Delaune
|
|
|
|
|
|
That looks useful. My TCP app can post messages to a dialog so the user can determine the state of the thread. One dialog might display the status of several instances of the message app. I will have to figure out how the app will get the ID to that dialog, but it may well be useful.
Thank you for the tip.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
Messaging is likely the best alternative (although not the only option). It is also common for people to make invisible windows simply for the messaging mechanism (instead of handling it by hand as in the article below).
Your other alternative could be to have the window occasionally check a critical section (or mutex) protected variable to know the current state.
modified 6-Jun-14 12:42pm.
|
|
|
|
|
This MFC dialog is just a test vehicle to develop the classes and thread that will perform all the TCP/IP I/O. I will add a button to poll the events set by the TCP code, or maybe a button that starts a timer that leads to a poll every couple of seconds.
Thanks for taking the time to reply.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
I use the polling method for high-frequency updates to a GUI. Since messaging can lead to a flood of messages updating things at such a high-rate you probably wouldn't make out the least significant digits.
|
|
|
|
|
I have a win32 COM which is developped to work as win32 and it can be registred to run as surrogate dll with client application x64.
1) Before modification of it to be called into out_of_procces,this dll use Microssoft.Jet.oledb.4 to connect and create mdb files.and this was working fine.
2) after the modification to let this dll be loadded by x64 application as surrogate and changing the Microsoft.Jet.oledb by Microsoft.ACE
This dll not work now when version of office is x64.
And this is normal because it is x32
Questions:
- can i check at run time if the dll is registred as x32 or x64 ?
- if yes can i define the driver of office related to the version of dll at run time
Ie:
If registred as 32 then use Microsoft.Jet.oledb
Else if dll surrogate (x64) then use Microsoft.ACE
Thank you
|
|
|
|
|
Hi,
Think outside the box. By calling the IsWow64Process function[^] you can detect whether or not you are loaded into a 32 or 64 bit process and act accordingly.
Best Wishes,
-David Delaune
|
|
|
|
|
Windows 7, Visual Studio 2012, winsock
Edit: Oops, posted in ATL rather than C++. If you are an admin type, please move it.
How is an event associated with a socket operation? For example:
[code]
iResult = listen(ListenSocket, 1);
[/code]
The socket is non-blocking and the code continues while waiting for the listen operation to complete. I want event: CLIENT_DETECTED (arbitrary name, I know how to create the event.) to be triggered when a client solicits a connection. Yes, I understand a bunch of code is needed to capture that event and do something.
Thank you for your time.
modified 18-May-14 22:06pm.
|
|
|
|