|
What is the type of m_port?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Sorry, I realised as soon as I submitted it that I hadn't put enough info, but couldn't find 'Edit'.
'm_port' is a class which handles the serial comms.
This is the code for the function 'Write'
DWORD CSerialPort::Write(const void* lpBuf, DWORD dwCount)<br />
{<br />
ASSERT(IsOpen());<br />
ASSERT(!m_bOverlapped);<br />
<br />
DWORD dwBytesWritten = 0;<br />
int nResult = WriteFile(m_hComm, lpBuf, dwCount, &dwBytesWritten, NULL);<br />
if (!nResult)<br />
{<br />
TRACE(_T("Failed in call to WriteFile\n"));<br />
AfxThrowSerialException();<br />
}<br />
<br />
return dwBytesWritten;<br />
}
So it actually uses 'WriteFile' to write the data to the serial port.
Ali
|
|
|
|
|
Alison Pentland wrote:
anything more than that loses the upper bit
This may be a stupid question but… how do you know that? If you mean the application reading the data is missing the upper bit how do you know it is not the reading that is the problem?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
It is not a stupid question, here is the answer.......
I have an analyser attached to the the serial port, it displays all the data from the Rx & Tx lines on the RS232 port. My code 'talks' to an instrument that we design and I write the firmware for.
The problem is that when I write 0x96 to the port I get 0x16 out. I have traced through the code and I can see the data in the array is correct when I pass it to the 'WriteFile' function.
I can't understand it as it is the same code I have been using for months! Any ideas gratefully received.
Thanks,
Ali
|
|
|
|
|
Big Big Smile!
Thank you, your question has prompted me to find my problem. I realised that the only reason I believed that I had a problem was the display on the 'Serial Analyser'. I was on holiday last week and it had a firmware upgrade while I was away. So I checked through the settings and found that the number of data bits was set to 7! (when it should have been & was previously 8)
I use the Analyser almost every day and I never change the settings, so it just didn't occur to me that it might be wrong ..... until you asked me how I knew it was writing the data that was the problem. You can probably tell I am very happy to have resolved it!
Thank you, thank you, thank you
Ali
|
|
|
|
|
Hi. I recently wrote a small MFC app that saves files in my own format .cmp
I also managed to associate this file extension with windows so my files have their own cutom icon rather than the default windows one. I learned how to do it from here (cool stuff): http://www.codeproject.com/w2k/extendingshell.asp
Now I am facing one problem. When I double-click on any saved file say stored on my desktop then my application opens as it should but it doesnt open my file.
Obviously its because when my application initializes it should know the name of the file that I selected to open but I am not sure how to retieve this info. I guess when I right-click on the saved file and select from a context menu "Open this (.cmp) in my app" the shell Command will call my app and somehow pass the name of the file.
So basically I am not sure how to read this command line arguments in my MFC app so I could get the name of the file and open it immediately after my app initialization. Actually would it be a command line or some other way of doing it? how do I tell my app what file I am opening.?
Please let me know if its very easy solution for it.
In that tutorial the author calls:
C:\Windows\Notepad.exe %1
but I guess "%1" means nothing to my app as my app would not recognise what that is. I think I should replace %1 with my own command like "open" or "print" to distinguish the action my app should perform. Am I right? Please let me know if you could. Thank you..
|
|
|
|
|
Did you use AppWizard to create your application? If so, a .reg file would have been created in the project. Has RegisterShellFileTypes() been called from the application object? This is what registers the document types with the shell (e.g., Windows Explorer). After that, you should see a .cmp key under the HKEY_CLASSES_ROOT hive. Note the value of the (Default) value. That should also exist under the HKEY_CLASSES_ROOT hive. For example, if the extension were .txt instead, you'd see a .txt key under the HKEY_CLASSES_ROOT hive. The (Default) value is txtfile, so you'd also see a txtfile key under the HKEY_CLASSES_ROOT hive. The HKEY_CLASSES_ROOT\txtfile\shell key will have keys named open, print, and printto. Note the difference (the /p command-line parameter) between the command that opens versus the command that prints.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
No. I did update registry myself. all keys are added and working well! its just when you right-click on the filename.cmp it opens teh program which is correct but the programas isnt able to know what file was selected.
|
|
|
|
|
robert_s wrote:
...but the programas isnt able to know what file was selected.
Did you add the %1 parameter to the registry entry? That is what gets replaced with the selected file? In your application, you can get access to the command-line parameters via the m_lpCmdLine member.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes I added %1 in registry
c:\Documents and Settings\user\My Documents\Prog\Prog.exe %1
Is it correct?
but I am not sure whether it should be separated by space or a comma ','
when I add the following code to:
BOOL CProgView::PreCreateWindow(CREATESTRUCT& cs)
{.....
LPTSTR str = ::GetCommandLine();
AfxMessageBox(str);
..}
The str contains one long string
"c:\Documents and Settings\user\My Documents\Prog\Prog.exe c:\Docum~1\use~\Desktop\test~1.cmp"
I guess its what I should get but its a bit silly to have one long string as it will be a hassel to separate one argument from the other as the are blank spaces all over the place so it will be hard to determine where to split it.
|
|
|
|
|
robert_s wrote:
c:\Documents and Settings\user\My Documents\Prog\Prog.exe %1
Is it correct?
Be sure and put double-quotes around the %1.
robert_s wrote:
its a bit silly to have one long string as it will be a hassel to separate one argument from the other as the are blank spaces all over the place so it will be hard to determine where to split it.
Can you use the CCommandLineInfo class? If not, __argv[1] is always available.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
Is it possible to have a multidimensional CArray (how do you declare it?) or do you have to write one yourself?
tnx for your help.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Yes, it's possible. Something like:
typedef CArray<int, int> intArray;
CArray<intArray, intArray> bigArray;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
tnx for your reply. At first it seemed to work, but when I actually used it, the "intArray" (the typedef CArray) doesn't recognize the CArray functions like Add, RemoveAll, ...
and
when I add my typedef CArray to the normal CArray, the compiler complains of an illegal use of this type as an expression
Do you also have an answer to this?
tnx for your time!
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
OK found it thanks.
(forgot to make an object of the typedef )
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I was just wondering how I could get access to the command line arguments in MFC? I know in C it would have been the argv[] parameter in the main, but I don't know how to get that in MFC.
Thanks, David
|
|
|
|
|
toothless boots wrote:
I was just wondering how I could get access to the command line arguments in MFC? I know in C it would have been the argv[] parameter in the main, but I don't know how to get that in MFC.
MAY BE THIS CLASS WILL HELP YOU class CCommandLineInfo
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
toothless boots wrote:
I know in C it would have been the argv[] parameter in the main
You can still use __argc and __argv . From the application object, you have access to the m_lpCmdLine member.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
My Q is for both VS 6.0 and .NET.
One of my projects has up to 50 classes. Is there some way to organize the classes like for e.g. the way I do with files and folders in windows explorer?
Thanks
_____________________________
...and justice for all
APe
|
|
|
|
|
Right-click the project, select New Folder. Name the folder. Start dropping classes into it.
In VS 6.0, the folder structure is stored entirely in the workspace .opt file (.vco if you're using eMbedded Visual C++).
Visual Studio .NET's folder structure exactly matches the on-disk structure. You can't create folders in Class View, but you can create folders in the Solution Explorer. The Class View can be organised by namespace; it represents the logical, not the physical, view of the code. Often it's a good idea to match namespaces and disk folders.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
You mean the way you do with packages in Java?
Thanks
_____________________________
...and justice for all
APe
|
|
|
|
|
I have created a Pagesetup dialog object like this:
CPageSetupDialog psd( PSD_INTHOUSANDTHSOFINCHES | PSD_MARGINS |
PSD_ENABLEPAGEPAINTHOOK, this );
Normally In the Oriantation part in the Setup dialog,defaultly select Portrait checkbox.
But I want to select Landscape check box as a default,when Dialog box appearing.
please send me a reply ,if any one know that.....
thanks...
How to select Landscape button as a default in PageSetupDialog
|
|
|
|
|
how can i connect to usb?
|
|
|
|
|
Ehm, the USB connectors can usually be found at the backside of your computer. They're small rectangular connectors.
If your computer is not equipped with these, it's massively outdated. A remedy is a plugin PCI-USB controller.
If that's not the answer you've hoped for: be more specific when attempting to formulate a question.
What do you want to do by what means?
|
|
|
|
|
I mean how can i send data through usb using c++
|
|
|
|