|
Strange, it used to say:
If the function fails, the return value is zero. To get extended error information, call GetLastError() .
"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
|
|
|
|
|
Hi all,
I am trying to read a file from a device connected to a serial port. I am using CreateFile() and ReadFile() methods to read the file. But my problem is when i am not using FILE_FLAG_OVERLAPPED parameter my processing becomes slow. I wanted to know why this is happening??
Can anybody help me in this?
Thanks in advance
|
|
|
|
|
I think that is quite hard to guess without actually seeing what you do and how you do it. My guess is that without overlapping your program blocks on the read operatin until there's data available to be read so the processing becomes "blocky". Do you know the difference between overlapped and non-overlapped IO?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
If you have not read it before you MUST read: http://www.flounder.com/serial.htm[^]
You'd think working with a serial port be easy, but it's far from.
Good luck,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
I would like to address several bytes of memory but different bits from different locations. The program I am using is on an embedded system and I need access to different pieces of the peripherals. Specifically when dealing with ports where something connected crosses multiple ports and I need a modular way to access them through a simple 'maskport = value' and you only need to modify some macros or a enum to change things instead of each functions code.
IS this even allowed or am I out to lunch? (I am using GCC)
For example: (this doesn't work btw but it was my attempt)
struct bits {
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1;
} __attribute__((__packed__));
#define SBIT(port,pin) ((*(volatile struct bits*)&port).b##pin)
struct FIELD {
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1;
};
struct FIELD test;
test.b0 = SBIT(0xE2, 0);
test.b1 = SBIT(0xE2, 4);
test.b2 = SBIT(0xE2, 7);
test.b3 = SBIT(0xEF, 2);
test.b4 = SBIT(0xEF, 3);
test.b5 = SBIT(0x07, 1);
test.b6 = SBIT(0x07, 5);
test.b7 = SBIT(0x07, 6);
test = 0x7A;
That way by assigning a value to test:
<br />
test = 0x7A;
0xE2:
<br />
0001 0000<br />
0xEF:
<br />
0000 1100<br />
0x07:
<br />
0010 0010<br />
|
|
|
|
|
If I understood, you can try with a union:
union FIELDEX
{
struct FIELD
{
uint8_t b0:1;
uint8_t b1:1;
uint8_t b2:1;
uint8_t b3:1;
uint8_t b4:1;
uint8_t b5:1;
uint8_t b6:1;
uint8_t b7:1;
} fld;
uint8_t val;
};
FIELDEX test;
test.val = 0x7A; // 0111 1010
test.fld.b0 = 1; // set bit 0
|
|
|
|
|
I would still have the problem of setting separate address bits, however your example would make a good compact bitfield definition.
I am trying to take bits from separate registers and create my own 'masked register' so when I write to my register it sends each bit to its specified bits in other registers.
test.b0 = SBIT(0xE2, 0);
test.b1 = SBIT(0xE2, 4);
test.b2 = SBIT(0xE2, 7);
test.b3 = SBIT(0xEF, 2);
test.b4 = SBIT(0xEF, 3);
test.b5 = SBIT(0x07, 1);
test.b6 = SBIT(0x07, 5);
test.b7 = SBIT(0x07, 6);
Hopefully this will show more clearly what I am after:
test = 0x7A;
|
|
|
|
|
Hi All
If I can delete a memory using delete keyword for memory allocated on heap using new keyword.
class A
{
} ;
A &a1 = * (new A ) ;
How to release memory which is holded by a reference.
|
|
|
|
|
This looks very ugly. Why do you need to have something like that ? I guess you need to revise your design a bit.
Anyway, did you try to delete the address of the reference: delete &a1; ? I never done this myself so I don't know if this works but it looks like the obvious solution.
|
|
|
|
|
delete &a1 is exactly what he has to do. It works perfectly.
It may sound unorthodox, but depends how a1 is used: if a1 participate into arithmetic expression of overloaded operators inside generic code, it cannot be a pointer, and *a1 may be not suitable for template function expecting references.
Generic programming changes a lot the "traditional rules".
(Note: you can also have a nullable reference as *(A*)0 that can be checked as !&a ).
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
|
Hi all,
i have an long string which displayed in Static text control but its not fully displayed,i want to display it in muliline if string is too long and not contain any new line or space.
please help me for this.
thanks in advance.
|
|
|
|
|
The default property of a 'static control' is to support text wrapping. Set the 'No Wrap' property to 'False' if it is set as True by mistake.
|
|
|
|
|
|
Ok, what about resizing the static control at run time, according to the text length ?
|
|
|
|
|
Without spaces text will not wrap in a static control.
You will have to do it yourself by inserting a newline or space at the appropriate place.
The NoWrap property is to tell the static control not to wrap the text even if there is a space or newline character in the text.
I would recommend you use an edit control instead.
Set its Auto HScroll property to False , Read Only to True and Border to False to get a similar visual effect as that of a static control.
Setting Auto HScroll to False will wrap the text even if there is no space or newline characters.
The only difference is that, in a static control you cannot select text and in an edit control you will be able to select text using the mouse.
Also for a static control you can set the text from the property window, while you cannot for an edit control. You will need to use the SetWindowText API to set the text for an edit control.
|
|
|
|
|
To insert newline at apropriate place in string, he can use GetTextMetrics(), and insert '\n' at every (staticCtrlWidth/textMatrics.tmAveCharWidth) position of string. Or any other way?
|
|
|
|
|
That can be done, but the output of a string like "iiiiiiiiiiiiiiWWWWWWWWWWWWWWW" would not be as expected.
|
|
|
|
|
Yes.. average character width makes the problem. Need to track the extend of each character, and apropriately insert the '\n'.
|
|
|
|
|
Hi,
How can I set bitmap or image on CDateTimeCtrl on updown button?
|
|
|
|
|
I am reading id3v2 frame headers from an MP3 file. I am able to read some headers correctly. I read that the frame header TLEN has the total length of the file in milliseconds. The problem is that I have encountered some MP3 files which do not have this frame header "TLEN". I have used Groove Hex editor to check and they are all true. How do I calculate the total length of the file if it does not have the TLEN frame header?
|
|
|
|
|
Me think that the TLEN tag is only informative (option) and not essential. so you will have to find your track lenght somewhere else (probably decode and check the header frame
see this : MPEG Audio Frame Header[^]
M.
Watched code never compiles.
|
|
|
|
|
As Maximilien suggested, to decode and get the duration, render the file using DirectShow, IGraphBuilder::RenderFile(). Obtain IMediaSeeking interface and call GetDuration(). That wil give you the correct duration.
|
|
|
|
|
I am not programming in directshow but I am doing it in C. I want to understand it well so I don't want to use a library.
|
|
|
|
|
well.. if you are programming in C for windows, still you can use directshow, its a part of windows sdk now. Only need to know the usage of COM.
|
|
|
|