|
hi
i think this is because invalid source ID. that means u may have deleted some Resource(Dialog Controls) and Forget to remove those ID from ur source files(resource.h,ur project source file)
Cheers
JP
|
|
|
|
|
oops! Sounds like something I would do. Thanks for the help.
|
|
|
|
|
Thats perfect!!!!
Thanks Mike
|
|
|
|
|
Hi all
How can i get current system time in microseconds resultion?
thanks.
|
|
|
|
|
i would say that you can't get more than milliseconds.
|
|
|
|
|
Are U sure?
If so, Do you have any idea how the guys at "Rational" added the abitlity to show time in microsecs in Quantify?
thanks.
|
|
|
|
|
Have a look at this codeproject article that will answer your query:
Timing Article[^]
I Dream of Absolute Zero
|
|
|
|
|
I have been using a DOS C program for several years which obtains system time in 100 microsecond increments, though you could do better. It reads the internal timer, along with the tik time, to give improved resolution.
My version uses a floating point calculation, which precludes using the floating point emulator.
I'll email you the brief source code.
David Knoble
Tupelo, MS
|
|
|
|
|
Can you send it to mee too ?
Thank you !
Marcello
|
|
|
|
|
Since there appears to be no email, but only public and private postings, I'll post the source code here. The routines in 'interpts.h' are self-explanitory: install interrupts, including the clock-tick interrupt, which occurs every 18.2ms. The functions clock_tick is chained to this interrupt, and merely counts elapsed time, whose origin happens to be the installation of interrupts, but could be anything.
The routine mtime() happens to be used within an irq4 routine -- I want to know the time when a serial event occurs. It should be unnecessary to have mtime() occuring within an interrupt. Note that irq4 has lower priority than irq0.
A good (old) book on DOS programming might also help.
copy an paste:
/*
mtime.h
Purpose: get time with 100 microsecond resolution.
The resolution could be microsecond, but is 100 microsec because the
time is being stored as integers in a huge array.
*/
#if !defined(MTIME_DEFINED)
// convert mtime struct to seconds as double
#define MTIME_TICKS_PER_SEC 10000.0
#define mtsec2sec(x) ((double)(x) / MTIME_TICKS_PER_SEC)
typedef unsigned long mtime;
#define MTIME_DEFINED
// defs for clock_tick()
#define CLOCK_FREQUENCY 1193180UL // frequency of 8253 timer
#define CLOCKTICKS_PER_TICK 65536UL // clock ticks before interrupt occurs
#define CLOCK_TICKS_PER_SEC\
((double) CLOCK_FREQUENCY / CLOCKTICKS_PER_TICK)
#define SECONDS_PER_CLOCK_TICK\
((double) CLOCKTICKS_PER_TICK / CLOCK_FREQUENCY)
#endif
extern volatile unsigned long tick_time;
extern const double seconds_per_tick,
tenth_milliseconds_per_tick;
extern int interrupts_installed; // true when interrupts are installed
// current time from tick time - accurate to 50 msec.
#define current_tick_time() (tick_time * seconds_per_tick) // clock in seconds.
mtime msec10_time(void); // get time in 1/10 msec
int clock_tick(void); // accumulate clock_ticks on int 08
// eof
//***********************
/*
mtime.c
Purpose: determine time from tick_time and 8253 timer. Time is obtained
in 100 microsecond (tenth millisecond) units.
Also has interrupt routine which updates clock tick at each
bios clock-tick (18.2 times per second) - IRQ0.
Method: tick_time (from interpts.c) is updated with every bios tick, as
part of timer interrupt IRQ0. msec10_time() takes that tick
count, and the timer value (which is microsecond resolution),
and combines them for accurate time. If the timer tick, as
determined by the IRQ0 routine which increments it, is different
before and after the input instructions, then the input will be
done a second time (and won't infringe on another timer tick
increment). Note that tick_time *must* be declared volatile, or
the compiler will not retrieve it again at the end of the loop,
but will rather "optimize" this part away.
*NOTE* Floating point calculation used. The computer *must*
have a math coprocessor, and the software must be compiled
*without* the emulator option, since the emulator uses
software interrupts, and the calling program could be
doing a fp calc when this routine is called.
*NOTE* time will overflow after 5 days.
Portions learned from Mark Piggott, Compuserve 100316,454
Thanks Mark.
*/
#include <conio.h>
#include "interpts.h"
#include "mtime.h"
#define TIMER_CTL_PORT 0x43 // Mode Control Register
#define TIMER0_PORT 0x40 // Counter 0
//#define TIMER_CFG 0x36 // Timer 0, Write LSB then MSB, Mode 3, Binary
#define TIMER_READ 0x00 // Timer 0, Latch, Mode 3, Binary
// Timer countdown frequency / 10000
#define TFREQ_10000 (CLOCK_FREQUENCY / MTIME_TICKS_PER_SEC)
// static int is_mode2 = 0; // true after first call - not used for now
volatile unsigned long tick_time = 0; // clock ticks since installation
const double seconds_per_tick = 1.0 * SECONDS_PER_CLOCK_TICK, // cf interpts.h
tenth_milliseconds_per_tick = MTIME_TICKS_PER_SEC * SECONDS_PER_CLOCK_TICK;
#pragma intrinsic(inp, outp)
#pragma check_stack(off) // can't use stack check on interrupt routines
//#pragma optimize ("", off)
//======================================================================
mtime msec10_time(void)
{
static unsigned int timer_count, // combined 8253 register value
pending0; // true if irq0 pending
static unsigned long ticks; // copy of tick_count on entry
static unsigned char lsb, msb; // lsb and msb of timer count
/* Obtain timer values. Note, this routine is used within an IRQ4 routine,
whose priority is less than IRQ0. This, tick_time may be incremented
while the routine is executing. Confirm whether or not this happens
*/
// Obtain ticks and timer values. If IRQ0 interrupts (tick_time change),
// then do it again.
// do
{ ticks = tick_time; // bios time from IRQ0 add_on (below)
(void) outp(TIMER_CTL_PORT, TIMER_READ); // Counter 0, Latch, Mode 3, Bin
lsb = (unsigned char) inp(TIMER0_PORT); // lsb
msb = (unsigned char) inp(TIMER0_PORT); // msb
// since ints disabled, is irq0 pending?
(void) outp(ADDR_8259_OCW3, IRR_REGISTER);
pending0 = inp(ADDR_8259_OCW3) & IRQ0_PENDING;
}// while (ticks != tick_time);
// timer is count down - invert to count up
timer_count = (msb ^ 0xff) << 8 | (lsb ^ 0xff);
if (timer_count < 0x8000 && pending0) // if irq0 is pending, fix ticks
ticks++;
return (mtime)
(ticks * tenth_milliseconds_per_tick + timer_count / TFREQ_10000);
}
//=========================================================================
int clock_tick(void)
//Interrupt routine for IRQ0 - timer interrupt
{
tick_time++;
return 0;
}
//==========================================================================
// eof
//****************************
/*
interpts.h
Purpose: prepare for, and clean up after, installing an interrupt drive
for COM1 for the appleton photometer.
Method: Prepare for the interupt by installing the interrupt driver,
and then masking the 8254 for IRQ4, and enabling interrupts.
This interrupt is *not* chained to the previous one.
Clean up consists of turning off the mask for IRQ4, and
removing the interupt driver, replacing with the original.
*/
// (various com port defines removed here.)
#define IRQ0_PENDING 0x01 // is irq0 pending?
// data output to PIC:
#define IRR_REGISTER 0x0a // interrupt req register (pending ints)
#define ISR_REGISTER 0x0b // In-service register (pending or being served)
#define EOI 0x20 // EOI code to end this interrupt
void interrupts_install(int allo_light); // install interrupt
void interrupts_free(void); // free interrupt
void com_on_off(int on); // turn com on and off
// eof
//***************
//end-of-posting
Dave Knoble
|
|
|
|
|
Thank you very much,
I will also update my informations
Cheers,
Marcello
|
|
|
|
|
I'm have a strange problem with on_exit and signal. I wrote a simple console program which catches the Ctrl-C command (use signal and fgets) and calls exit. I use On_exit to assign a function which runs when the program exits. However, the program exits out just fine but does not run the exit routine. The program does call the exit routine when it exits without the Ctrl-C. Any advice? I have been able to catch the Ctrl-C. Instead of calling exit, I do a simple print statement. Individually they work but note together.
|
|
|
|
|
Hi
I'm trying put en richedit box in my dialog and when i try to run the program nothing happens. I have tried with AfxInitRichEdit() and used create() function but id didn't helped. Is there someone that is expert at this area.
Thanks in advance
WBR
Edi
|
|
|
|
|
Where do you call AfxInitRichEdit()?
You must call it before the dialog is displayed!
A typical place to call this function is in your program’s InitInstance member function.
|
|
|
|
|
Thank you. I had put it in OnInitDialog() but now i have removed it to InitInstance() and i works so long.
Thanks again.
WBR
Edi
|
|
|
|
|
I have to translate the following statement from VB to VC++:
CodeKey = "TheKey"
For i = 1 To Len(DataIn)
intXOrValue1 = Asc(Mid(DataIn, i, 1))
intXOrValue2 = Asc(Mid(CodeKey, ((i Mod Len(CodeKey)) + 1), 1))
strDataOut = strDataOut + chr(intXOrValue1 XOr intXOrValue2)
Next
This is an encryption algorithm, composing strDataOut by xoring characters from the original string and the string to be encrypted.
I tryed to convertit like this:
CString CodeKey = "TheKey"
for(int i=0;i
|
|
|
|
|
char *lpCode = (char*)malloc(256 /* <> ??? */ * sizeof(char));
char *p = lpCode; // p points to lpCode's end
strcpy(lpCode, "TheKey");
int i1, i2;
for(int i = 0; i < DataIn.GetLength(); i++)
{
i1 = DataIn.GetAt(i);
i2 = *(lpCode + (i % (int)(p - lpCode));
strDataOut += (i1 ^i2);
}
this may not work because of the modulus operator. but the main thing is: CStrings::GetLength() returns the difference between the position of the NULL char in the string and the beginning of it. use pointers instead like p to count manually the bytes that were added so one knows through the difference (p - lpCode) lpCode's length.
hope this helps
|
|
|
|
|
How do I get the number of serial ports available under Windows 2000?
Prefer to have a solution using win32.
|
|
|
|
|
Look at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM and see if that's at all helpful.
Tim
|
|
|
|
|
See Joaquín M López Muñoz's article here on CodeProject: Another serial port enumerator[^]
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Whether does exist Microsoft Visual C ++ for Windows64-bit (no PreRelease)? If yes, how to receive it.
VladimirH
|
|
|
|
|
I don't think there's even a pre-release. For the moment, you need to use the compiler from the Driver Development Kit[^].
|
|
|
|
|
You are mistaken. Pre-release exists.
|
|
|
|
|
Hi
I have a problem with PKZIP using MFC.
I run the PKZIP program but it gives me an error:
PKZIP: <e7> Can't create: PKBACK# 001
I have looked into 'E7' ... not enough permittions put i have all permittions to write in the needed folder.
Any ideas?
Jens
|
|
|
|