|
Is there any replacement for DeviceIoControl() to connect to CD-ROM and send an IOCTL_SCSI_PASS_THROUGH_DIRECT request to it?!
Thanks in advance
|
|
|
|
|
DeviceIoControl is the only documented API to call into a kernel mode driver.
I guess you could do the same using assembly language hacks.
|
|
|
|
|
Hi all,
I have made a sdi application, in that application i have made a splitter control. On Left and right side of splitter control i have placed a class derived from CFormView.
I want to disable my window when a particular processing is going on. How can i disable my main application window.
Thanks in advance
|
|
|
|
|
What do you mean by disable the main window? If your particular process is on the main thread then it will effectively be disabled. If not, then you should set a mutex or other flag to suspend all other threads.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
dear all
i am a newbe, only want to test my program via 2 winsock. client send a data and server can receive data, that is all. anyone can help me? thanks a lot
|
|
|
|
|
Try searching the articles here on CodeProject. If you still cannot find any useful samples then try Google/Bing.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
thanks. i searched already, all are the 2 applications, i just want one application for 2 winsock senddata. thanks
|
|
|
|
|
zhiyuan16 wrote: i just want one application
What do you mean by one application? Even if the server and client exist on the same computer they still need to run independently. If you want to run them as a single application then you will need to create different threads for them. Much simpler to have the two separate applications which can then run independently in their own windows.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
i only want to send data from client winsock, and when server receive data, then i want to do other things. that is all. so i only need one application to apply 2 winsock. thanks
|
|
|
|
|
A proper server would use threads; and a proper client would use threads too. I see no obstacles for having both the server threads and the client threads running together in one process, hence a single app. Just search good examples of server and client, then combine them.
However, when you do that, what is the purpose of your sockets? it is demoted to a simple inter-thread communication scheme then. For which other solutions exist, such as queues, Windows messages, and probably many more.
|
|
|
|
|
Luc Pattyn wrote: A proper server would use threads
I often handle both client and server in a single thread context in an application. This is called asynchronous networking or non-blocking sockets... e.g. used by lighttpd.
|
|
|
|
|
you're right, one can use asynchronous operations instead of threads. I tend to prefer threads as asynchronous operations seem more complex, but I do realize they can be a good choice, and have the advantage of saving on stack memory at the expense of some more code.
Also, when borrowing existing code in order to join a server and a client, I expect a thread-oriented approach would be easier to merge than an asynchronous one.
|
|
|
|
|
Luc Pattyn wrote: I expect a thread-oriented approach would be easier to merge than an asynchronous one.
It's just copy and paste. Here is a server/client example (last two code snippets), which you can join together in a single application. It wouldn't be very different with MFC's CAsyncSocket or QT's networking classes. I think the asynchronous networking model has is strengths with applications, where you want to focus on protocol an functionality and less on synchronisation and timing.
/M
|
|
|
|
|
yes, OK. Great link BTW.
|
|
|
|
|
As Luc says, why use sockets within a single application when you can just use a message queue, shared memory etc. However, since you are doing the implementation it is entirely your choice.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
thanks a lot. anyone has such example source code. can anyone send me here. only exchange the data. thanks a lot
|
|
|
|
|
zhiyuan16 wrote: anyone has such example source code. can anyone send me here.
What are your requirements? We know how you want to do it, but not what. Could you describe more detailed what it is you want to solve, for example if you have a practical application problem or experimenting with winsock, then it is much easier to recommend something.
|
|
|
|
|
i just want an example source code with 2 winsock can be run in one project. and can communicate each other.thanks
|
|
|
|
|
|
There are lots of sample winsock applications, both here on CodeProject and out where Google will find them. However there probably will not be many with both client and server code in the same app. As has been suggested more than once, you will need to take the code for both halves and put it together for your requirements.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I have been using the following code to access individual bits of memory to use as bit fields for a white but I am not really sure how the heck it works. I now need some extended functionality and as I do not understand how it works I can not upgrade it myself.
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 FMAN(ADDR,FLAG) ((*(volatile struct bits*)&ADDR).b##FLAG)
#define FIFO_EOF FMAN(0x20,1)
FIFO_EOF = 1;
expands to:
((*(volatile struct flags*)&_SFR_IO8(0x20)).b##1) = 1;
Theirs a few casts and pointers in their to make it confusing but Im going on an understanding that it is taking the value of the bits structure and applying the rusult to the memory location 0x20. I wish to upgrade this functionality by using c++ and some added structure so I could have a bitfeld access like below.
Memory location: 0x14000000
bitfield: RX0E, TX0E, RXB0E, TXB0E ..... etc
I would need to somehow initilize my custom bitfiled to the memory location easily so I can include it in my communications class. So in my code I would have the ability to set the entire bitfiled with one word or by individual bits.
COMMS->FLAGS = 0x90000000
COMMS->FLAGS->RX0E = 1;
if(COMMS->FLAGS->TXB0E)
Does that make since? I know its possible as all the source code I have poked around in for ARM based processors use this exact method but the implementations are closed source and I have never figured it out. I use GCC if you are wondering.
Anyone care to take a show at helping me figure out how it works and then how to get my desired results? Thanks!
|
|
|
|
|
a partial answer:
1.
FIFO_EOF = 1;
does not expand to:
((*(volatile struct flags*)&_SFR_IO8(0x20)).b##1) = 1;
it does expand to:
((*(volatile struct flags*)&_SFR_IO8(0x20)).b1) = 1;
as the ## operator inside macro's concatenates strings to yield new identifiers.
2.
you could have something like:
struct bits {
uint8_t RX0E:1;
uint8_t TX0E:1;
uint8_t RXB0E:1;
uint8_t TCB0R:1;
...
} __attribute__((__packed__));
but then of course there no longer is any b0, b1, ...
3.
you could have a union of both structs, then both ways of accessing bits are available.
|
|
|
|
|
Hi,
The C++ Standard Library provides various classes to deal with bit fields: std::bitset<size_t> [^] which is oriented to individual bit manipulation, and the specialized std::valarray<bool> and std::vector<bool> . You should consider using them instead of your C like constructs.
With all of them you can use placement new to allocate at a specific memory position.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
One cool thing about C++ is that you can keep doing hardware specific stuff in C style structures then add member functions to do the disgusting macro hackery and chicanery that you have to do to simplify your code. So for example if you've got a linear address for a 386 or later you can break it up in the same way as the processor does:
union linear_address_decoder
{
struct decoded
{
unsigned page_directory_entry_ : 10;
unsigned page_table_entry_ : 10;
unsigned offset_ : 10;
}
decoded_;
void *encoded_;
linear_address_decoder( void *p ) : encoded_( p ) {}
unsigned page_directory_entry() const
{
return decoded_.page_directory_entry_;
}
};
Anyway it sounds like you want to go the other way (assembling a value to be stored in memory) but the principle is the same:
- Declare a union of the bunch of bit fields you're interested in and a primitive type that fills the memory location you want to read/write it from
- Add a constructor that takes the component bits and sticks them in the bit fields
- Have a recovery function to write the assembled value somewhere in memory.
Hope that helps - if I'm not being clear drop us a line and I'll try and clarify things.
Cheers,
Ash
|
|
|
|
|
Thanks for the replies!
Luc: "you could have a union of both structs, then both ways of accessing bits are available" Could you give me an example of this union of two structures? I'm not sure how it would work as I would think each structure would have a different memory location.
Alain: "std::bitset<size_t>" I did not know of this capability. It is quite close to what I want and will be helpful while in visual studio but my GCC compiler does not have STL support only the standard set of c libraries. I'm going to take a look at how they implemented it and see if I can work with it but have not looked yet.
Aescleal: I have gone through some sites on placement specifically http://en.wikipedia.org/wiki/Placement_syntax[^] and It clearly states it does what I want and places something at a given memory location but nowhere in the examples do I see the new object being assigned to a specific location. Can you give me a breakdown on how you would place a 32bit value at memory location 0x14000000 using placement new?
Any other suggestions? I'm still poking code around unsuccessfully.
|
|
|
|