|
I am hoping someone out there can point me in the right direction.
What I have is a Dell 9300 Laptop that only has USB ports
My problem is I am a EET Student with a Lab project board (MDE8255-1 LPT)
info here: http://www.microdigitaled.com/hardware/mdelpt/MDELPT.htm[^]
that is designed for communication via parallel port.
What I have is a USB to Parallel adapter I picked up from Fry's. It is a "Syba USB 1.1 to parallel port cable". with Drivers built by MOSchip
Info Below:
http://www.moschip.com/html/MCS7705.html[^]
http://www.moschip.com/data/products/MCS7705/Data%20Sheet_7705.pdf[^]
what I want to do is write some code in Visual Studio.Net VC++ to handle the communication between my laptop and the trainer board. What do I need to do to setup a communication channel?
I've searched MSDN and tried their example for communication through COM1 and modified it for LPT3, that is what my USB-Para is installed as. I've searched this site and tried some of the example from
http://home.ict.nl/~ramklein/Projects/Serial.html[^]
and
http://www.codeproject.com/system/AsefPortAccess.asp[^]
These don't work for me with a little mod here or there. I am sure I am doing something totaly wrong. That is why I have come here for some guidance.
What do I need to do to get even just some rudimentary communication to and from the trainer board.
If any one is able to respond to my request don't be afraid that I am not able to read. Post all the links to resources that are usefully on this subject and be as detailed as you like. Ohhhh, and I love examples. The more the better.
|
|
|
|
|
Since it is USB you need to communicate with the driver. There are typically control, input and output calls for this. Beyond that I suspect you will need to talk to the manufacturer to get the API.
Elaine
|
|
|
|
|
Thanks for this clarification. I'll look into that method some more. If there is any other advice in how to use API's I will be very grateful as I have never worked with them before.
|
|
|
|
|
Is there a way of ignoring escape characters? For example, I want to pass "c:\temp\testfile.txt" instead of "c:\\temp\\testfile.txt" as a parameter in the following declaration:
CSentenceAr SentenceArray("c:\\temp\\testfile.txt");
Jon
|
|
|
|
|
|
The compiler will convert the "\\" to "\", so "c:\temp\testfile.txt" is what will be passed into your constructor. Maybe I'm misunderstanding your question?
I think you can also use "/" instead of "\\", but I'm not 100% sure about that.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi there,
I've been developing a virtual web-cam DirectShow filter. I'd like to load a video file and transmit
it as if it comes from a WebCam.
At first I used the ISampleGrabber interface and tried to pass on the buffers I received from it.
Unfortunately, I had some wierd problems that the window that was supposed to receive the bitmaps
sometimes didn't get WM_PAINT messages fast enough and only once in a while. In other times it seemed
to be okay.
However, I decided to try something else: I built a filter graph and removed the Video Renderer filter. Then I saved the output pin to the Video Renderer filter (before removing it) and delegated
the IPin functions to that pin.
The problem is that when I use GraphEdit to connect a renderer to my filter, after the connection
both filters disappear from the filter graph. I know it has something to do with the connection of
the pins.
Is it possible to connect two pins from different filter graphs?
Is there maybe another way to do it?
I'd immensely appreciate any help!
Thanks.
|
|
|
|
|
DobosCake wrote: ... and transmit
it as if it comes from a WebCam.
You lost me here. What do you mean by transmit it as if it comes from a webcam? It really just sounds like a file source filter to me...
DobosCake wrote: At first I used the ISampleGrabber interface and tried to pass on the buffers I received from it.
Unfortunately, I had some wierd problems that the window that was supposed to receive the bitmaps
sometimes didn't get WM_PAINT messages fast enough and only once in a while. In other times it seemed
to be okay.
Pass on what buffers? From where? To where? Are you taking the samples and BitBlt-ing yourself? The video renderers that come with windows don't wait for a WM_PAINT message to draw. If the renderer can't process samples fast enough it might start dropping samples.
DobosCake wrote: I built a filter graph and removed the Video Renderer filter
And what filters does this filter graph it consist of? Why would you build a complete playback graph only to remove the video renderer filter? If you would like to customize the graph you build without too much hassle use the ICaptureGraphBuilder2 interface.
DobosCake wrote: The problem is that when I use GraphEdit to connect a renderer to my filter, after the connection
both filters disappear from the filter graph.
I've never seen filters disappear by themselves off GraphEdit, usually they just crash GraphEdit if they are buggy. I think you should debug your filter and step through the media type negotiation phase.
|
|
|
|
|
Thanks for your reply.
hfry wrote: You lost me here. What do you mean by transmit it as if it comes from a webcam? It really just sounds like a file source filter to me...
If you use Skype, for example, when using video in Skype you can choose what device you want to get
your video from. My source filter appears as part of the capture devices in the list. The tweak here
that it's not connected to any hardware. Instead, A file dialog pops up when you choose it, and you're
supposed to choose a video file (i.e: AVI file). Then my source filter should simply is supposed to play the file and output the video AS IF it comes from a real WebCam.
Internally, I built a regular filter graph (using IGraphBuilder::RenderFile with the file you choose from the file dialog).
hfry wrote:
And what filters does this filter graph it consist of? Why would you build a complete playback graph only to remove the video renderer filter? If you would like to customize the graph you build without too much hassle use the ICaptureGraphBuilder2 interface.
hfry wrote: Pass on what buffers? From where? To where? Are you taking the samples and BitBlt-ing yourself? The video renderers that come with windows don't wait for a WM_PAINT message to draw. If the renderer can't process samples fast enough it might start dropping samples.
The reason I'm removing the Video Renderer filter is because my filter shouldn't render the video. Just like a WebCam driver/filter doesn't have a renderer. It is added and connected externally (to the filter). I simply have to output what comes into the Video Renderer.
Atleast, that's the way I see it. I might be (completely) wrong.
When I used the Sample Grabber, it got the buffer that I want to pass on in another thread. For some reason which eludes me, the player (which is an external program) sometimes just didn't refresh the picture properly. Only once in a while. If I reran the file - sometimes it was just fine!
hfry wrote: I've never seen filters disappear by themselves off GraphEdit, usually they just crash GraphEdit if they are buggy. I think you should debug your filter and step through the media type negotiation phase.
This is unrelated to the Sample Grabber issue, because I tried another approach. I decided to relinquish DirectShow's classes, and implemented most of the interface I needed myself. That's because I tried to just get the output pin of the filter that was connected to the Video Renderer (before I removed it) and delegate the calls from my output pin to that output pin, so that the
next filter (which is NOT in my internally built filter graph) would actually connect to that filter
and receive what the Video Renderer would have received.
I used GraphEdit. I added my source filter, and a Video Renderer. Then, when I connected them they suddenly disappeared. Since I was in debugging mode, I know they didn't crash. Actually they connected - but I assume that this problem is related to the fact that the pins are in different graph filter. My filter delegates the IPin calls to a pin which is in my internal filter graph, whereas the Video Renderer I added in GraphEdit is in GraphEdit's filter graph. I"m not sure though.
I know it sounds very complex.... that's why I'd appreciate any help.
Thanks.
|
|
|
|
|
Ok, sounds pretty nasty. So I think your two methods are
1) "Capture" filter creates an internal graph with sample grabber. When sample grabber provides sample, copy the data in the sample into the buffer your "capture" filter gets from its allocator and pass that sample along.
2) "Capture" filter creates an internal graph and connects the output pin of the last filter in the chain with the input pin being provided.
Never faced with something like this before, the first method is workable. I *think* the second one might work. I guess there is quite a bit of delegation of calls to other interfaces (Run(), Stop() etc from the filter to the internal graph manager or I think you can do it yourself by going through the filters upstream and calling Run() etc).
I guess one thing to be careful about is that all the filters have agreed on actual memory allocators that are allocating the sample buffers since you are connecting them up in such a manner.
DobosCake wrote: sometimes just didn't refresh the picture properly
This *could* be because the format that you are requesting off the sample grabber isn't the preferred format of the video renderer (which like YUV media types). Kind of a stab in the dark though. If you use GraphEdit do you see this as well? You might want to try with all the 3 different video renderers.
DobosCake wrote: Internally, I built a regular filter graph (using IGraphBuilder::RenderFile with the file you choose from the file dialog).
I tend to dislike breaking pins after they get connected as sometimes that filter could be buggy and might get stuck in a wrong state. I generally prefer to use IGraphBuilder::AddSourceFilter() to get the source filter, and then ICaptureGraphBuilder2::RenderStream() to string the filters up together. You could string up the SourceFilter -> SampleGrabber -> NullRenderer.
|
|
|
|
|
Thanks for your response.
hfry wrote:
1) "Capture" filter creates an internal graph with sample grabber. When sample grabber provides sample, copy the data in the sample into the buffer your "capture" filter gets from its allocator and pass that sample along.
So that's what I did, and it's working perfectly for quite a lot of files.
I also add the Color Space Converter filter right before the (removed) Video Renderer filter, because some applications want to change the media format.
I still have one problem though. For some files, I don't know exactly
when, but apparently when the format is changed, it breaks the pin of
the Sample Grabber. In SetFormat, I sometimes have to reconnect pins
myself because that's what the documentation says you have to do when you change the format of an already connected pin. I do that successfully, but somewhere afterwards (I'm not sure yet when...), by the time I get to FillBuffer(), something disconnects again.
I also tried to connect filters in GraphEdit the same way I do in my filter. For connection combination you see that the Sample Grabber disconnects and has to be reconnected again. I still don't get it...
Any advice?
|
|
|
|
|
|
kitty5 wrote: I wouldn't need to use new(), correct?
you would most certainly use new[] with an array that large. it's bad practice to put such a large array on the stack.
|
|
|
|
|
Chris Losinger wrote: you would most certainly use new[] with an array that large. it's bad practice to put such a large array on the stack.
if it's a double array would you do:
<br />
ULONG *buff;<br />
buff = new ULONG [1000][1000];<br />
do I access buff the same as an array?
i.e. buff[0][10] = 0x12345678;
Thanks!
Kitty5
|
|
|
|
|
kitty5 wrote: do I access buff the same as an array?
yes
|
|
|
|
|
The following code is intended to clear garbage from a fixed array of strings, however I am getting the following errors, the first of which (I think) is the most relevant:
SentenceAr.cpp(13): error C2440: '=' : cannot convert from 'const char [1]' to 'char'
SentenceAr.cpp(20): error C2144: syntax error : 'void' should be preceded by ')'
SentenceAr.cpp(20): error C2059: syntax error : ')'
SentenceAr.cpp(21): error C2143: syntax error : missing ';' before '{'
SentenceAr.cpp(23): error C2601: 'CSentenceAr::readFromFile' : local function definitions are illegal
SentenceAr.cpp (extract)
CSentenceAr::CSentenceAr(char strFileToRead[MAX_FILENAME_LENGTH + 1])
{
// Initialize strSentence
{ for (int iLineNumber = 1; iLineNumber <= MAX_LINES; iLineNumber++)
{
for (int iCharPos = 1; iCharPos <= MAX_SENTENCE_LENGTH; iCharPos++)
{strSentence[iLineNumber] [iCharPos] = "";}
}
readFromFile(strFileToRead);
}
...
SentenceAr.h
#define MAX_LINES 100
#define MAX_SENTENCE_LENGTH 1000
#define MAX_FILENAME_LENGTH 40
#define MAX_WORD_LENGTH 10
class CSentenceAr
{
public:
CSentenceAr(char strFileToRead[MAX_SENTENCE_LENGTH + 1]);
virtual ~CSentenceAr(void);
void sortSentences(bool bAscending); // implements BubbleSort
int HowManyWords(char strWord[MAX_WORD_LENGTH + 1]);
char strSentence [MAX_LINES + 1] [MAX_SENTENCE_LENGTH + 1];
private:
void readFromFile(char strFileToRead[MAX_SENTENCE_LENGTH + 1]);
};
SentenceAr.cpp (whole)
#include ".\SentenceAr.h"
#include <fstream>
using namespace std;
CSentenceAr::CSentenceAr(char strFileToRead[MAX_FILENAME_LENGTH + 1])
{
// Initialize strSentence
{ for (int iLineNumber = 1; iLineNumber <= MAX_LINES; iLineNumber++)
{
for (int iCharPos = 1; iCharPos <= MAX_SENTENCE_LENGTH; iCharPos++)
{strSentence[iLineNumber] [iCharPos] = "";}
}
readFromFile(strFileToRead);
}
CSentenceAr::~CSentenceAr(void)
{}
void CSentenceAr::readFromFile(char strFileToRead[MAX_FILENAME_LENGTH + 1])
{
char strLine[MAX_SENTENCE_LENGTH + 1];
short iLineNumber = 1;
fstream fileToRead(strFileToRead,ios::in);
while (!fileToRead.eof())
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
// copy strLine to strSentence for each iLineNumber
for (int iCharPos = 1; iCharPos <= MAX_SENTENCE_LENGTH; iCharPos++)
{
strSentence[iLineNumber] [iCharPos] = strLine[iCharPos];
}
iLineNumber++;
}
}
}
Jon
|
|
|
|
|
My guess is that you need to do some reading on what C style strings are. Any good reason why you are not using std::vector and std::string?
Arrays start at index 0. Why do you allocate more memory just to get it to start at index 1? Just do strSentence[iLineNumber-1] when accessing your array.
for (int iLineNumber = 0; iLineNumber < MAX_LINES; iLineNumber++)
{
strSentence[iLineNumber][0] = '\0';
}
char strSentence[MAX_LINES][MAX_SENTENCE_LENGTH + 1];
Use strcpy instead. Code below is an idea of what strcpy is doing. This is why C style strings are refered to as NUL ('\0') terminated.
int iCharPos = 0;
while(strLine[iCharPos] != '\0')
{
strSentence[iLineNumber][iCharPos] = strLine[iCharPos];
iCharPos++;
}
strSentence[iLineNumber][iCharPos] = '\0';
-- modified at 10:28 Sunday 23rd July, 2006
|
|
|
|
|
how can i implement the NM_CUSTOMDRAW message for the default Toolbar for an MDI application (toolbar ID = IDR_MAINFRAME) ?
thanks in advance ..
k_dehairy
|
|
|
|
|
See Here[^] maybe it is some helpful to you
|
|
|
|
|
I already drived a class from the CToolBar and implemented the
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
within it, and it worked fine untill I implemented the xp theme manifest in the application!!
why is that? I don't know? .. I need help on that
thanks very much for your care .. really
k_dehairy
|
|
|
|
|
I see this problem when i use manifest in app (of course i use combobox derived)
|
|
|
|
|
Hi,
I am looking for an example of a CListCtrl derived class
which implements static columns. These are columns which
are excluded from a horizontal scroll, so it is possible
to scroll horizontal through a large list control, leaving
some important columns permanently in view. Can anybody help
me to a link or say how exactly it is done.
tia.
|
|
|
|
|
Did you see examples from Listctrl in codeproject
|
|
|
|
|
No, cann't find any examples.
|
|
|
|
|