|
Iain Wiseman wrote: and found xerces-c was not able to access the file for reading in the same process. You really need to explain that in technical terms, i.e. what code you used and what errors you received. I'm not sure about item 1, but 2,3 and 4 are quite straightforward in Windows.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I want to disable other processing from locking the file.
When I use CreateFile, this works except it also prevents Xerces from reading the file so the code looks a little like this
m_Handle = CreateFile(
TEXT(inFullyQualifiedPath.c_str()),
GENERIC_ALL,
0,
NULL,
OPEN_EXISTING,
NULL,
NULL);
m_ConfigFileParser = new xercesc::XercesDOMParser;
m_ConfigFileParser->parse(m_Filename.c_str());
The reading of the file fails because Xerces cannot open the file.
|
|
|
|
|
Solved by using
GENERIC_READ and FILE_SHARE_READ | FILE_SHARE_WRITE
|
|
|
|
|
Iain Wiseman wrote: FILE_SHARE_READ | FILE_SHARE_WRITE You do understand that those options allow other processes to read and write the file at the same time.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
If this isn't correct then is there something that is?
It seemed to work when I ran a separate process with the same code and put a pause in it.
I totally sure you are right. If you do know the right combination I would be grateful. It seemed such a simple thing to want to do.
Iain
|
|
|
|
|
Sorry, I'm not sure exactly what your problem is. You said it works now, I was just pointing out that those options mean you do not have exclusive access to the file.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I am simply after in one process being able to prevent someone else opening a file whilst I am reading it. I do not have control over the opening of the file as this is done within the Xerces library. The file is an xml file hence the use of xerces. Once I have completed the read I want to sometimes delete the file.
Ideally I would have like to in my process
Check I have exclusive rights to the file
Read it using xerces
Delete it
|
|
|
|
|
A Simple work around to your problem would be use your original code to get the exclusive access to file,
Read the file and create a temporary file which you can pass it to Xerces.. later delete the temp file.. and if you want delete even the source/original file.
Other alternatives could be to check if xerces takes text(some temp buffer) as input instead of file name.. so you can read the file in buffer and pass it to xerces.
|
|
|
|
|
Iain Wiseman wrote: I do not have control over the opening of the file as this is done within the Xerces library. In that case there is nothing you can do to gain exclusive access to it. I have no experience of the Xerces library, but are you sure there is no option to pass the handle of a previously opened file into it?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I did in the end copy the file to a temporary file which gets destroyed on destruction.
Thanks all for your help.
|
|
|
|
|
|
I don't think this should be addressed to me.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Don't you read the file if the access is denied to delete it?
Otherwise, simply try to delete the file using DeleteFile. It will give you ERROR_ACCESSDENIED return code if it fails.
Alternatively you can check the File Security information Check Here[^]
-Sarath.
Rate the answers and close your posts if it's answered
|
|
|
|
|
I AM A LITTLE BIT EXPERIENCED WITH C PROGRAMMING AND PICS BUT AM WONDERING IF ANYONE OUT THERE CAN HELP WITH THE CODE TO RUN A PIC16F8777A OR AN ARDUINO WITH TWO IR SENSORS S1 AND S2 TO PERFORM BIDIRECTIONAL COUNTING IN AND OUT. IN THE FIRST SEQUENCE BREAKING FIRST S1 AND THEN S2 WILL TELL THE MICROCONTROLLER TO INCREMENT THE COUNTER WHILE BREAKING THE SECOND SEQUENCE, FIRST S2 AND THEN S1 WOULD TELL THE MICROCONTROLLER TO DECREMENT THE COUNTER.THE MICROONTROLLER SHOULD ALSO STORE AND TIMESTAMP THE COUNTS AND BE ABLE TO PASS THE TIMESTAMPED DATA TO A REMOTE COMPUTER VIA BLUETOOTH OR WIFI.
ANY HELP WILL BE GREATLY APPRECIATED.
THANK YOU.
|
|
|
|
|
Are the sensors tied to a GPIO line or do you have to talk to them using IIC or SPI? Need a little more info about the sensors before I could offer more assistance. I'm familiar with ARM (mostly Freescale and Atmel stuff) and I'd say that the sensors that I work with are generally tied to a GPIO pin. In that case you just need to read the GPIO pin status or tie it to an interrupt and read them in your app. The logic handling should be simple enough, if S1 is tripped before S2 then increment your counter and log the event to whatever permanent storage you are using, and decrement if you see the sensors in the opposite order. Not having much experience with PIC parts I don't know the exact registers you would need to check for the GPIO status though.
|
|
|
|
|
I am tieing a pair of infrared sensors S1 and S2 onto GPIO lines(digital I/O) of any microcontroller that is easy to program in C as I am new to this.I am looking into ARDUINO UNO(ATmega328 MCU),ARDUINO MEGA(ATmega1280) or a PIC16F877A.I will use the Microcontroller to read the interrupts from the sensors as they change on being broken in the sequence mentioned before.
My main problem is the real coding in C of the logic onto my app.
Can you help with the code?? I wish to have the following functionality:
1) Read interrupts from sensors
2)Increment or decrement counter depending on sequence they are broken
3) timestamp the count and enable storing
4) Pass timestapmed data onto a remote host computer via bluetooth or Wifi.
Do you suggest any parcticular Microcontroller for this application?
Thank you very much.
|
|
|
|
|
Try something like the following for your interrupt handlers. Depending on the micro you select, how to install these will be different. I would stay away from PIC parts, I personally don't like them. The Atmega family of MPU should be better to work with in my opinion, although my personal favorite these days is the Freescale Kinetis family of MPU's. You can get demo boards in the form of expandable towers from Freescale.
[EDIT] You may also want to handle rollover for the counter variable if you expect to have counts high enough for this to happen.
#define S1 (1 << 0)
#define S2 (1 << 1)
unsigned char sensorFlags = 0;
int counter = 0;
void s1_isr(void)
{
if(sensorFlags & S2)
{
--counter;
sensorFlags &= ~S2;
}
else if(sensorFlags & S1)
{
}
else
{
sensorFlags |= S1;
}
}
void s2_isr(void)
{
if(sensorFlags & S1)
{
++counter;
sensorFlags &= ~S1;
}
else if(sensorFlags & S2)
{
}
else
{
sensorFlags |= S2;
}
}
modified 7-Nov-12 14:05pm.
|
|
|
|
|
Hi Tr@V,
This is great mate and I appreciate your help so much.
I am thinking of going for either ARDUINO MEGA/ARDUINO 2560
which have ATMEL 1280 and ATMEL 2560 chips respecetively.I will probably have to connect a bluetooth or wifi shield and a SD card for storing.Am not much aware of Freescale Kinetis family of MPU's you suggested but will check them out.
Any chance I can get your email address or phone number incase i hit hard rocks?I may need your help.I'll also let you know how far have gone.
Thanks.
|
|
|
|
|
I have made some good progress with my ISR and am serial printing the count on the serial monitor, now what I want to achieve is to call the count to be displayed on my 3 digit seven seg cc display or rather let the ISR trigger the counts whenever the sensors flag depending on their sequence. I have the code to count from 0-999 back to 0 so my problem is how to combine with the ISR. Any help is much appreciated.
Much thanks.
|
|
|
|
|
Kindly gurus,
Assist me in the below questions. I am new in C++ and even don't know where to start. Please somebody help me out
Write a program using functions that prompts for the input of social security numbers upto a maximum of 10. Store the social security numbers in a two dimensional array of characters. Ask if the array of social security numbers is to be sorted in ascending or descending order, then call a bubble sort function that you write to sort the array. The program should print the unsorted list first, sort the list, then print the sorted list. The bubble sort algorithm is as follows:
A. Start with the first two array elements.
B. Compare the elements and exchange them if the
compare function indicates they should be swapped.
C. Bump up one element and repeat step B.
D. Continue until the end of the array is reached.
E. Repeat steps B -> D decreasing the upperlimit on
the array by one for each iteration of the loop.
In other words, stop one element short of the
previous iteration in the main loop.
F. End the sort if:
1. No exchanges occur during an iteration or
2. The upper limit for the loop reaches one.
|
|
|
|
|
Member 8856752 wrote: Assist me in the below questions.
You haven't asked any questions.
Member 8856752 wrote: Please somebody help me out
See here[^].
|
|
|
|
|
Member 8856752 wrote: Write a program That looks very like an instruction telling you to do some assignment for school or college. So, if someone here wrote it for you, would you still expect to submit it as your own work?
It would be better if you made an effort to write at least part of it, and come back here with more specific issues when you get stuck.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Since you've already written the pseudo-code, it should be straightforward to convert it to working code.
Anyway, you can always do:
- an internet search for "bubble sort implementation in C++"
- then compare the steps there with the ones you've listed
- modify the code there to suit your requirements
- run and test it
- and, most important, make sure that you understand, and are able to explain each line of your code.
|
|
|
|
|
Hi All,
i need to return input value after press enter. how to make it. need little help.
the main think here that i have to make function that return value after press Enter.
here is link of project file.
https://skydrive.live.com/redir?resid=78B222720843DE16!116&authkey=!AAjKOKZHSd-q9lI
i have a dialog box with 2 EditBox (m_TxInput and m_TxOutPut) and 2 Button for (GetString and GetNumber)
i made class CMyTextBox for m_TxInput . here is code below. i have 2 function GetString and GetNumber in CMyTextBox Class. i am calling these function on button down in dlg.
class CMyTextBox : public CEdit
{
public:
CMyTextBox();
public:
public:
bool InFlag; CString RetVal;
public:
CString GetString();
double GetNumber();
virtual ~CMyTextBox();
protected:
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
DECLARE_MESSAGE_MAP()
};
void CMyTextBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nFlags == 28) GetWindowText(RetVal);
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
double CMyTextBox::GetNumber()
{
if (InFlag == true)
return atof(RetVal);
return 0;
}
CString CMyTextBox::GetString()
{
if (InFlag == true)
return RetVal;
return "";
}
Thanks
Amrit
modified 2-Nov-12 14:29pm.
|
|
|
|
|
This is not the best way to implement a dialog. You should allow the user to fill in the various fields and then capture the data when the OK button is pressed. In general you do not need to check for key down characters, since most CEdit classes offer other methods and events for checking the content, and the CDialog class offers the UpdateData() [^] method to capture all fields.
One of these days I'm going to think of a really clever signature.
|
|
|
|