|
Hi!
I work under Visual C++ 2008 and use the libusb driver and library for windows to communicate with a self-build camera device. The acquired images are transfered via usb bulk transfer and I can collect the data from the endpoint by calling usb_bulk_tranfer function of the libusb library. The transfer rate of the image data is about 12MB per second. Unfortunately, some data gets lost periodically every few milliseconds, probably caused by usb interrupts or something else which has a higher priority. Is there a way to ensure the bulk tranfer by disabling other tranfers or events while images are tranfered via bulk?
Any help is greatly appreciated.
|
|
|
|
|
USB gives least priority to bulk endpoints.
But there should not be any data loss.
Please post some relevant code.
|
|
|
|
|
Hi all, I am writing a console application that now plays .mp3 and PCM wav files. Now I want the application to also read .cdfs audio but I don't know where start. Any detailed tutorials and descriptions will do. I can do it in either C or C++. Thanks.
|
|
|
|
|
Have you tried ffmpeg? Its an open source project with LPGP license. I haven't heard about cdfs, but there's a good chance it's supported.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello,
I run EnumProcesses(), to find if the progam "NurOper.exe" is running I debuged it and although "NurOper.exe" is running its don't return it,
its return all ather programs include my program- "nurman.exe" what can be the resone for it ,I must know if the progam "NurOper.exe" is running in order not to run it twice,
thank for advance .
the code is:
bool IsRunning=false;
int num=0;
DWORD aProcesses[1024], cbNeeded, cProcesses;
ULONG lCpuusage = 0;
UINT index;
double percent;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses),&cbNeeded ) )
return false;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
CString str;
for (int i = 0; i < cProcesses; i++ )
if( aProcesses[i] != 0 )
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE,aProcesses[i] );
// Get the process name.
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod,sizeofhMod),&cbNeeded))
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR) );
}
}
str=(CString)szProcessName;
// Print the process name and identifier.
if(str.Compare(L"nurman.exe")==0 )
if(num==0)
num=1;
else if(num==1)
exit(1);
if(str.Compare(L"NurOper.exe")==0 )
IsRunning=true;
CloseHandle( hProcess );
}
if(!IsRunning)
_beginthread(runExe, 0, (void*)12 );
|
|
|
|
|
|
Why do you think, it was "not returned" ?
virtual void BeHappy() = 0;
|
|
|
|
|
I saved the names of all processes, I debuged it and the names of all ather processes besides "NurOper.exe" were on the array .
|
|
|
|
|
...and "nUrOpEr.exe" - as well ?
I would perform it by the combination of
- Process32First : EXE name stage, and
- Module32First : EXE directory stage
Please see the following example :
bool GetPathFromPID(DWORD dwPID, CString& cszFullName)
{
bool bResult = false;
cszFullName.Empty();
HANDLE hToolHelp = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
if (INVALID_HANDLE_VALUE != hToolHelp) {
MODULEENTRY32 ModuleEntry32;
ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
if (Module32First(hToolHelp, &ModuleEntry32)) {
do {
CString cszModule(ModuleEntry32.szModule);
CString cszExePath(ModuleEntry32.szExePath);
if (0 == cszExePath.Right(cszModule.GetLength()).CompareNoCase(cszModule)) {
cszFullName = cszExePath;
bResult = true;
break;
}
} while (Module32Next(hToolHelp, &ModuleEntry32));
}
CloseHandle(hToolHelp);
}
return bResult;
}
bool GetRunningProcesses(const CString& csDir,
CStringArray& arrProcesse,
CDWordArray& arrProcessID,
DWORD* pdwFoundCount)
{
arrProcesse.RemoveAll();
arrProcessID.RemoveAll();
if (pdwFoundCount) {
*pdwFoundCount = 0;
}
HANDLE hToolHelp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hToolHelp == INVALID_HANDLE_VALUE) {
return false;
}
PROCESSENTRY32 ProcessEntry32;
ProcessEntry32.dwSize = sizeof(PROCESSENTRY32);
CString cszOurDir(csDir);
cszOurDir.MakeUpper();
if (Process32First(hToolHelp, &ProcessEntry32)) {
do {
if (ProcessEntry32.th32ProcessID) {
CString cszExePath;
if (GetPathFromPID(ProcessEntry32.th32ProcessID, cszExePath)) {
cszExePath.MakeUpper();
if (-1 != cszExePath.Find(cszOurDir)) {
arrProcesse.Add(ProcessEntry32.szExeFile);
arrProcessID.Add(ProcessEntry32.th32ProcessID);
}
}
}
} while (Process32Next(hToolHelp, &ProcessEntry32));
}
CloseHandle(hToolHelp);
if (pdwFoundCount) {
*pdwFoundCount = arrProcessID.GetCount();
}
return true;
}
PS: an administrator only can see the all processes by this code,
other users can see the own (their) processes only...
virtual void BeHappy() = 0;
modified on Monday, September 6, 2010 4:58 AM
|
|
|
|
|
First,thank you for yours helpfull answer,
I would like to ask you how can I have an access to the name of each procces, i.e I need to chack whether certain program is active.
thanks again
|
|
|
|
|
Please see the usage of the field ProcessEntry32.szExeFile in the second function above
virtual void BeHappy() = 0;
|
|
|
|
|
Just a thought, but have you looked at Process32First() and related functions?
|
|
|
|
|
How many processes does Task Manager report? How does that compare to cProcesses ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hello Everybody !
when I call the system font dialog like this,how to set the default font name and size ?
HFONT FAR PASCAL MyCreateFont( void )
{
CHOOSEFONT cf;
LOGFONT lf;
HFONT hfont;
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = (HWND)NULL;
cf.hDC = (HDC)NULL;
cf.lpLogFont = &lf;
cf.iPointSize = 0;
cf.Flags = CF_SCREENFONTS;
cf.rgbColors = RGB(0,0,0);
cf.lCustData = 0L;
cf.lpfnHook = (LPCFHOOKPROC)NULL;
cf.lpTemplateName = (LPSTR)NULL;
cf.hInstance = (HINSTANCE) NULL;
cf.lpszStyle = (LPSTR)NULL;
cf.nFontType = SCREEN_FONTTYPE;
cf.nSizeMin = 0;
cf.nSizeMax = 0;
ChooseFont(&cf);
hfont = CreateFontIndirect(cf.lpLogFont);
return (hfont);
}
Thanks for your reply !
Best Regards !
|
|
|
|
|
It took me 10 seconds to google one word and find the answer, in the form of this sentence:
If you set the ... flag in the Flags member and initialize the other members, the ChooseFont function initializes the dialog box with a font that matches ...
|
|
|
|
|
I'm sorry...
thanks !
|
|
|
|
|
No problem.
|
|
|
|
|
Hi guys, i try to write my data into a binary file, but j have some problem in it . I dont know what happening inside..
class Person{
char Name[50];
char Address[10;
bool sex;
short age;
public:
Person();
Person(char* name, char *address, bool sex, short age);
const char* GetName() const;
const char* GetAddress() const;
};
ostream& operator<<(ostream& out, const Person&p)
{
out.write(reinterpret_cast<const char*>(&ap), sizeof(p));
return out;
}
istream& operator>>(istream& in, Person &p)
{
in.read(reinterpret_cast<char*>(&p), sizeof(p));
return in;
}
class Account_Property{
int account_number;
double amount;
bool account_type;
Person p;
public:
Account_Property();
Account_Property(Person p, int ac_num, bool ac_type, double amt);
int GetAccountNumber()const;
double GetAmount()const;
};
ostream &operator<<(ostream &out, const Account_Property &ap)
{
out.write(reinterpret_cast<const char*>(&ap), sizeof(ap));
return out;
}
istream& operator>>(istream &in, Account_Property &ap)
{
in.read(reinterpret_cast<char*>(&ap), sizeof(ap));
return in;
}
Thanks in Advance
|
|
|
|
|
Your problem is with
sizeof const Person& which should give the size of the reference and not the object.
Change
sizeof(p) to
sizeof(Person) etc.
|
|
|
|
|
Can you edit your article text to show symbols rather than XML entities?
I think Niklas is correct but it's rather hard to read!
|
|
|
|
|
I wrote a program that renders up to 200 characters that move across the screen at an 8 o'clock heading, isometric game style. I randomize each character's x and y coordinates and speed prior to rendering, which are rendered onto transparent quads. Since every object's z coordinate value is the same, the object rendered last is considered to have the least depth (e.g. it is rendered on top of everything else).
Now for my question: How should I go about ordering each object so that the ones with a greater y value are rendered after objects with a lesser y value? My rendering code currently runs through an array of the characters from 0-199 and resets, which causes some visually obvious depth problems.
To illustrate:
<br />
character[0].y = 1000;<br />
character[1].y = 1200;<br />
character[2].y = 200;<br />
They should be rendered in this order: character 2 -> character 0 -> character 1. I'm not sure how I can order them this way though.
Thanks for any help and ideas
Edit: Added example
modified on Saturday, September 4, 2010 2:15 AM
|
|
|
|
|
why not just use the GL depth buffer?
|
|
|
|
|
I thought you could only do that if objects had differing z coordinates. How do you use the depth buffer without it?
|
|
|
|
|
that's right, depth buffering is based on the z coordinate of each pixel (after the transforms are applied and things are in screen-space). I mentioned it thinking perhaps you could use that to your advantage and assign depths to the various characters and then let depth buffering handle overlapping cases.
|
|
|
|
|
I would like to do it this way but I'm not sure how I can while maintaining the isometric perspective I have set up. Currently every object in my program has a z value of -6.0f. If I change it the characters will appear to the program user as if some are bigger than others, which is not something I want to happen. Should I scale the size of my quads to compensate for the different depth values? Or am I making things more difficult than they really are?
Thank you for the replies
|
|
|
|