|
Hi Mick,
let me try to answer the questions clearly:
Q>> Do you want to detect when the device is plugged in or removed?
>>(This implies some way of enabling Plug-and-Play for the serial port).
>>I think this would be nice to have, but not necessary to get the driver >>working.
This is not necessary. I don`t see any advantage at the moment if we do so. But wait ... what about possible handshaking between hardware and ser-port. Could this cause a deadlock ? Maybe an app is sending midi-msg through the ser-device and the device waits for a handshake ? I`m not sure ...
Yes, I think we should keep the idea. We have several CPU`s in our hardware and it would not be to difficult to make them send an id-string back to the driver on request
>>Q> Do you need a MIDI application to 'see' the hardware on the serial port >>as a MIDI device?
Let me say some words about Cubase ( midi-sequencer-app ). Here you have for example 16 seperate tracks for midi-commands. For every track you can choose a different midi-out device if you have more than 1 device installed. So finally our driver should appear in this list, get the midi-commands from the track and send it via RS232.
>>(If yes, then it sounds like you want to write a 'layered' driver which >>sits between the MIDI device drivers and the serial port, rerouting MIDI >>commands to the serial port)
That`s it !
Thanks a lot ... Mario ///
P.S.: A LITTLE ENGLISH LESSON: I often read the "IMHO" - What does this mean ?
----------------------
www.klangwerker.de
mario@klangwerker.de
----------------------
|
|
|
|
|
OK, back again. A word of warning, I'm giving these answers on-the-fly, some info might not be 100% correct.
>But wait ... what about possible handshaking between hardware and ser-port. Could this cause a deadlock ? >Maybe an app is sending midi-msg through the ser-device and the device waits for a handshake.
The handshaking is set up by configuring the serial port (either via the serial port property pages or programmatically).
You should 'capture' the serial port when your driver inserts itself. This won't necessarily deadlock the machine if your driver blows it's stack or something, but may require a reboot to release and reset the serial port.
As far as the MIDI stuff goes, what you actually are writing is a *MIDI driver*, which uses the serial port. So your drivers should be enumerated by the system as a MIDI device, and query your hardware to enumerate all the midi devices on the serial port. The actual serial port access is the *easy* part.
You should be able to drive the serial hardware from user mode, but test performance first. Besides which, if you write it correctly, you can develop the driver fully in user-mode, then try a kernel-mode implementation only if you can't get the best performance.
Another point to note is that the device driver may integrate better with windows not as a pure MIDI device, but as some type of DirectMedia driver.
OK, that's as much useful advice as I can give....
Abbreviations
IMHO In My Humble Opinion
IMO In My Opinion
AFAIK As Far As I Know
RTFM Read The F*****g Manual (Note, this is *not* necessarily insulting)
ROFL Rolls On Floor Laughing (Also ROFLMAO, MAO - My A** Off)
WTF What The F***
Look for 'MIDI' & 'serial' in the MSDN & DDK. (That's a 'RTFM' (!))
Are you in Germany? Italiano or Deutsche? (I'm in Munich);)
|
|
|
|
|
Hi Mick,
thank you very much for giving advice.
I think now I know how to start-up dealing with driver-development and learning the basics.
Mario ///
P.S.: In fact - I`m from Germany and now I also know how to decode the english abbreviations
Greatings Mario ///
----------------------
www.klangwerker.de
mario@klangwerker.de
----------------------
|
|
|
|
|
Thanks for the thanks
Let me know how the project turns out.
There are three types of people in this world, those who can do arithmetic and those who can't.
|
|
|
|
|
I am certainly no expert having written only two simple parallel port drivers for 98 and NT but maybe I can give you a bit of advice.
1. Believe it or not, a Win98 driver is much harder to write than an NT (and I suppose 2000) driver. If 98 is not essential I wouldn't bother. In any case I would write for 2000 first and get the feel for how the driver works. Porting to 98 is easier after that.
2. Write a kernel mode driver. Although it's harder to write I think you will find that it gives you much better control and response. The fact that you are going to drive sound hardware almost mandates this.
3. You must understand re-entrant programming and especially clean and "dirty" (shared) data before you begin. The driver is written more or less as a set of parallel routines which are synchronised both by the kernel and by you. If you can write re-entrant code you are half way there.
4. Use a skeleton driver provided by the DDK or from the net. If you try to write it from scratch you will be releasing it for Windows 2010. The skeleton I used was very good and I didn't have to do very much to adapt it. I think you will find the same for the serial port.
5. You must develop using TWO PCs. Don't try to debug on a single machine. It's instant death and only an idiot (eg. myself) would try it. The DDK has tools for remote debugging and you should use these. Also, make sure that your target machine has absolutely nothing running on it. Clean all startup processes out even if you have to modify the registry. The less that's running the better you can debug the driver.
6. Do incremental development. Change one thing at a time. Remember that this is not a sequential process and lots of things are happening at the same time. Also remember that you are in kernel mode. You can kill the machine with a single keystroke.
7. Be extremely careful about memory allocation and deallocation for buffers and things. This is where you can get into real trouble. There are things which you can and cannot do in different parts of the driver.
8. Get two or three different books with lots of examples. I did this project a couple of years ago so the books I had are not relevant to you (and I had to leave them with my client) but I'm sure there is lots out there. Try to get one which uses a serial port driver as an example.
Although developing a driver is complicated it isn't as bad as it looks and it is fun when you get it to work. I hope this helps.
|
|
|
|
|
You don't say what windows platform you're developing for....
Just a few questions, then I may be able to help you.
Hardware:
Is it a new piece of hardware?
Off the shelf or in-house
Operating system:
XP/Win2k/NT4 or ME/98/95
Type of driver you are developing:
Kernel mode, user mode or both? (Or 'don't know'.)
If you are developing for NT based OS's, as far as books go, the 'classic' text is "The Windows NT Device Driver Book : A Guide for Programmers" by Art Baker, still relevant for Win2K, but a little dated now. (If you can get a cheap(==free) copy, it's worth having)
He has updated the book for Win2K, it's cunningly titled "The Windows 2000 Device Driver Book : A Guide for Programmers"
I have the first one, haven't got the latest one. The book is still useful, but if your a newbie, get the latest Win2K version.
You could also try "Windows NT Device Driver Development " by Peter Viscarola & W. Anthony Mason, another good book, which I also have. More up to date than the first Art Baker book, but published before Win2K was released.
The (first)Art Baker book is more of a "Device Driver Cookbook" then the Viscerola one.
Plenty of help is available in the DDK, (which is freee to download from MSDN now). But I recommend you get a book too.
Read the book reviews on Amazon.com, all three titles I have mentioned have been reviewed there.
(p.s. I also have another device driver book, but it's at home & I can't remember the title right now).
|
|
|
|
|
I got a question - see please the message:
"PropertySheet in CFrameWnd do not look like a Dlg"
but nobody answering me - what is wrong
Harald
Harald
mailto:development@langner.net
(Germany - Frankfurt at Main)
|
|
|
|
|
Hi,
I'm having real problems of understanding SetProcessWorkingSetSize and Virtual Lock. I've browsed the MSDN and scanned newsgroups but can't come with an complete answer.
I want to be REALLY sure that some certain memory NEWER reach the swap (paged out).
SetProcessWorkingSetSize and Virtual Lock seems to be a good hit but some documentation tells me that VirtualLock merely indicates that the memory belongs to a certain process. SetProcessWorkingSize is changeable by the operating system when the process goes to idle or getting really low of memory but on the other hand it prevents other applications to start if it is not memory enough...
I can't grasp how I should interpret the information about SetProcessWorkingSetSize and Virtual Lock.
Many thanks in Advance and Regards
Mario Toffia
|
|
|
|
|
If you don't want a certain data buffer to be swapped out, it's better to use something like the VirtualAlloc function. Take a look at the PAGE_NOCACHE flag.
The use of the SetProcessWorkingSetSize or VirtualLock functions is IMHO not a good idea for the purpose you want.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
Thanks for the reply!
I'm sorry for not setting up the problem correctly, this is how I'm using the working set/VirtualAllock,Lock (probrably wrong):
* SetProcessWorkingSetSize(48Mb,64Mb)
* VirtualAlloc(32Mb,MEM_COMMIT,PAGE_READWRITE|PAGE_NOCACHE)
* VirtualLock -- I Can se it loading all pages into memory (due to Page Fault count)
* Iterate through all the pages
* Running some other process which it wery memory inensive
* Iterate through all the pages
I'm still getting some (not many) page faults (i cannt tell if they are soft or "hard" since I don't have the tool (might be I'm stupid anyway).
When looking in Process Viewer I can see that the ProcessWorkingSetSize is less than requesten/GetProcessWorkingSetSize tells me?
If I'm removing the SetProc... windows will increase the WorkingSetSize form me...
What Am I doing wrong?
Regards
Mario Toffia
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
I want to create variable for 2 dialogs.
For example:
void CTestDlg1::OnOK()
{
m_str = "Hadi";
}
void CTestDlg2::OnOK()
{
m_str = "Rezaie";
}
So, i create Global.h :
char *m_str;
and adding on header of TestDlg1.cpp and TestDlg2.cpp:
#include "Global.h"
extern char *m_str;
But this code won't work ...
Please help me ...
Hadi Rezaie
|
|
|
|
|
Hello all,
I have an installer program written in Delphi 5 that I want to add an extension to. The developer of the installer gave the format of all exported dll functions that you call from the installer. The help states that:
DLL extensions must contain an exported function conforming to the following function prototype:
function ( MainHandle, DialogHandle: HWnd; const pInstallDir: PChar; pSupportDir, pUser, pCompany, pSerial, pAdditional: PChar ): Word; stdcall; export;
Since I'm writing the dll in VC++ as a Win32 dll this is what my code looks like in my cpp file.
#include "stdafx.h"
extern "C" __declspec(dllexport) WORD ValidateInformation(HWND MainHandle, HWND DialogHandle,
const char *pInstallDir, char *pSupportDir, char *pUser, char *pCompany, char *pSerial, char *pAdditional)
{
::MessageBox(MainHandle, "Inside ValidateInformation()!", "Serial Number Validation",
MB_OK|MB_ICONINFORMATION);
return 1;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
The stdafx.h file just has windows.h included in the header. What I have above compiles fine. When it gets called from the installer application, the messagebox displays it's message fine, but when it returns the installer crashes. The error states that the installer has performed an illegal operation and it will be shut down. Can anyone help me get this to work?
Thanks in advance.
--Tale
|
|
|
|
|
have you checked what function calling convention delphi uses?
it sounds like you might have a goofed up return address which is entirely plausible if the calling convention was wrong.
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Doesn't Delphi use __fastcall as default?
If so, VC++ uses in your case __stdcall and thats a another calling scheme.
|
|
|
|
|
Doesn't Delphi use __fastcall as default?
VC++ uses __stdcall in your case and thats a another param scheme.
|
|
|
|
|
I really need, a tutorial abou this. Can you help me ... someone !
|
|
|
|
|
There's a really excellent book called Database Programming with Visual C++ in 21 days that covers this. Best of all its online and free!
Got to www.informit.com and look under databases, ADO...
|
|
|
|
|
Great information. Thank you very, very much.
|
|
|
|
|
Ok, I've created a "full control" in atl object wizard.
Edit, radio, etc - ok, except listbox nd combo.
The subclassed listbox control window somehow becomes a little bit smaller, then dimensions i used in m_ctlZZZ.Create(...,rect,...)
why?
where to debug?
|
|
|
|
|
The dimensions you enter in Create(....) are for the control container, not the control itself. You need to increase the size of the rect in the Create(....) function to account for this. I don't know the exact amount though.
|
|
|
|
|
Don't you know, where to read about this fact? MSDN - ok, but where in MSDN
Why only ListBox has such behaviour?
|
|
|
|
|
<<< In the name of GOD >>>
Hi all.
Please explain to me about this pointer,
I read MSDN help, but i didn't understand.
Please help me ...
Hadi Rezaie
|
|
|
|
|
its a pointer to the current object that is used for all sorts of hidden and some overt things ... its kinda fundamental to the c++ language
for instance, in a dialog class you could set the window title by calling either:
SetWindowText(blah blah blah)
or
this->SetWindowText(blah blah blah)
it mostly gets passed as a hidden parameter in various calls between objects and can be used as a return value if you want to pass the address of the current object to another object
hmmmmmm ... is actually a very deep subject if you examine the full uses of it
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Good,
Now, What mean ::SetWindowText ???
Hadi Rezaie
|
|
|
|
|
you're kidding right?
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|