|
Quote: Didn't we used to call that a Control Block? A simple way to avoid having bullions and bullions of function parameters? Of course I am aware of the general technique (pass a struct instead of tons of parameters, again Windows API docet), however it is the very first time I hear the term 'Control Block' used with such a meaning.
By the way, you are welcome.
|
|
|
|
|
PIEBALD whips out his trusty "MS-DOS Programmer's Reference" (1993, "covers through version 6"!)... and it just says "structure", e.g. RWBLOCK structure .
And VMS uses "descriptors" which are similar.
"
The Descriptor
Classic C programming uses pointers to various structures, including null-terminated strings; ASCIZ strings. These are used within the OpenVMS standard C library, though most OpenVMS interfaces use descriptors. An OpenVMS construct that will be entirely new to even experienced C programmers is the string descriptor. This is typically a small data structure, containing the data length, data type, descriptor class, and data address for a chunk of data.
" -- http://labs.hoffmanlabs.com/node/273[^]
But I'm sure we used the term "Control Block" where I worked. Maybe it's from the UNIX culture? :shrug:
|
|
|
|
|
Quote: "MS-DOS Programmer's Reference"
Well, Carlo cannot argue with The Truth. 
|
|
|
|
|
Hi All,
While running a C++ Service in Wice indows 2008 Server i got below dump for service crash.
Crash Dump
------------
00 ntdll!ZwWaitForMultipleObjects+0xa
01 ntdll!RtlReportException+0x55e
02 ntdll!RtlReportException+0xbc
03 ntdll!RtlpNtMakeTemporaryKey+0x216
04 ntdll!_C_specific_handler+0x96
05 ntdll!wcstok_s+0x34be
06 ntdll!_chkstk+0x9d
07 ntdll!RtlRaiseException+0xf67
08 ntdll!RtlRaiseException+0x18d
09 ntdll!RtlpNtMakeTemporaryKey+0x1c0
0a ntdll!RtlpNtMakeTemporaryKey+0x3402
0b ntdll!RtlpNtMakeTemporaryKey+0x4000
0c ntdll!memset+0x160da
0d msvcr110!free+0x1c
0e wincli32!ConnectDlg+0x392
0f wincli32!OsGetCOPCLIVersion+0x7fed
10 ntdll!RtlActivateActivationContextUnsafeFast+0x114
11 ntdll!LdrShutdownThread+0x116
12 ntdll!RtlExitUserThread+0x3e
13 kernel32!BaseThreadInitThunk+0x15
14 ntdll!RtlUserThreadStart+0x34
please help me out.
Thanks,
Uday
|
|
|
|
|
janaswamy uday wrote: please help me out. With what? No one here has the remotest idea what program(s) you are running or where this error may have occurred.
|
|
|
|
|
|
Here's a quick run-down of the NEC protocol. http://techdocs.altium.com/display/FPGA/NEC+Infrared+Transmission+Protocol[^]
And here's some more general stuff: https://en.wikipedia.org/wiki/Consumer_IR[^]
A good place to look for the actual data/commands sent using the various protocols is in the microcontroller community. The Arduino/8501 forums/libraries have plenty of code available.
I once setup an arduino to record the incoming pulses from a remote. I then swapped the IR receiver module for a cheap 1mw laser - I can control the IR equipment from over 100m away now.
Unfortunately, the code's on a machine I dont have access to now and I've long since forgotten where I got the info from, sorry.
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Thank. 
|
|
|
|
|
|
Hello there. I have this structure in Header1.h and instantiating this structure in Header2.h. When I try to initialize this instance, I get this runtime exception. Here is my skeleton of code
HEADER1.h
struct Student {
CString Name;
CString Address;
CString Phone;
};
HEADER2.h
class CHeader2Dlg {
Student student;
}
HEADER2.cpp
void CHeader2Dlg::SomeFunction()
{
student.Name = "";
student.Address = "";
student.Phone = "";
}
|
|
|
|
|
Are you perhaps using the Unicode character set but assigning an ascii string?
Maybe it should be:
student.Name = L"";
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I changed that to L"" but in vein. Does it have to do anything with project settings ?
|
|
|
|
|
I suspect there is something more going on than just the code you have posted. It sounds as if the CString object is not being instantiated.
Maybe if you could post more, relevant code.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Header1.h
struct Account {
CString Name;
CString Address;
CString Phone;
};
Header2.h
class AccountDlg : public CDialog
{
Account account;
}
Header2.cpp
void AccountDlg::Load(int id)
{
CEdit* edit;
CComboBox *combobox;
account.Name= "asd"; account.Address= "asd";
account.Phone = "asd";
accountId = id;
accountSettings.AccountLoad(accountId,account);
}
|
|
|
|
|
That doesn't reveal anything more than the first post. I think you should post the actual code, not an obfuscated version of it.
Show the "#includes" as well.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Have you tried explicitly calling the struct's constructors in the class constructor?
class AccountDlg: public CDialog
{
Account account;
public:
AccountDlg() : account() {}
}
|
|
|
|
|
Django_Untaken wrote: Here I am getting the said exception What exception?
|
|
|
|
|
Access violation reading location. Just before this exception, if I debug the application, I see that member variables of this object dont show and Error reading characters of string shows up instead, in the intellisense.
|
|
|
|
|
That suggests that you have not initialised the object. Have you checked that the constructor is called and sets all the variables correctly?
|
|
|
|
|
It does not look like you are reading the string, you are actually assigning values. It seems the exception is from somewhere else.. Is this the complete code you are debugging ?? Could you please share the full code if possible ?
|
|
|
|
|
I am still struggling with pointers arithmetic.
Here is my crude test code.
I want to use pointers to access ( double - need triple eventually) the array of characters and do not get two things.
Problem #1 is probably how does the LCD class do the "print" and I can figure that one by myself. I do not expect this forum to be familiar with Arduino "library".
Problem # 2
I can print single characters in simple array by incrementing the pointer, but I cannot figure out why I cannot use same method on double array.
I really do not understand what is this error telling me
"error lvalue required as increment operand" - what is "lvalue" ?
Please keep in mind that English is not my native language so go easy on
" pointers to array..." "array of pointers" etc.
As always , I appreciate your help.
Cheers
Vaclav
Addendum
OK, I did some more reading about how the array is initialized and how the NAME of the array cannot be used the way I did try it.
So I did this - it "works" , but I am still not sure if it is correct or just a fluke.
char *pointer = stringTable[0];
lcd_i2c.print((char*) pointer++); // prints entire line
lcd_i2c.print((char*) pointer); // prints entire line starting with second character - expected that
Original post code starts here
char line[MAX_LINE] = "A TEST B";
int ncharacters = strlen(line);
char *sptr; // pointer to memory block returned by malloc
char *stringTable[NLINES]; // array of pointers to string
int i = 0;
sptr = (char*) malloc((unsigned) strlen(line) + 1);
lcd_i2c.clear();
lcd_i2c.print("Index ");
lcd_i2c.print(i);
lcd_i2c.setCursor(0, 1);
lcd_i2c.print("Length ");
lcd_i2c.print(ncharacters );
lcd_i2c.setCursor(0, 2);
lcd_i2c.print("pointer ");
lcd_i2c.print(sptr); // problem #1 prints the entire line - not really a problem here
strcpy(sptr, line); // copy line to pointed memory
lcd_i2c.print(sptr); // TOK prints pointer value ?
// copy pointer to first table array
stringTable[0] = sptr;
lcd_i2c.setCursor(0, 3);
i = 0;
do
{
// TOK prints first character from stringTable[0]
lcd_i2c.print((char) * (*stringTable)); // problem #1 prints only the first character - why it would be nice to print the entire line using pointers!
} while (*(*++stringTable)); error lvalue required as increment operand
-- modified 26-Jul-15 11:18am.
|
|
|
|
|
It's really rather difficult to figure out what you are trying to do since some of the above code makes no real sense. You are using casts on pointers that are already pointers, so do nothing except add confusion. You allocate a block of memory and then try to print it before it contains anything. You create an array of ponters for no apparent reason and then use only the first one, you copy data from one memory block to another, again for no real reason, etc. Maybe you should show exactly what problem you are trying to solve, without all this code and we can advise on the best option. And an explanation of what the print function actually does, or is supposed to do.
Also please use <pre> and </pre> tags around your code so it is more readable, like this:
lcd_i2c.clear();
lcd_i2c.print("Index ");
lcd_i2c.print(i);
lcd_i2c.setCursor(0, 1);
|
|
|
|
|
Well, you can easily look at the data-sheet for the I2C chip on the LCD board and at the one for the 1602/1604/2002/2004 LCD you're using. Once done, you can see that the LCD has a hardware cursor, and knows at which position on the display it is. It also has a means to write a character to the current cursor position.
Here's a quick list of the available commands: http://www.8051projects.net/lcd-interfacing/commands.php[^]
Not covered in that particular document, is the fact that you define custom bitmaps for characters - up to 4 or so at any one time. You could for instance, make a bitmap of a battery and then animate a charging display by changing the bitmap used for the battery 'character'.(but not actually changing the character drawn - it's the bitmap that this character refers to that is changed)
Here's a tool I whipped-up a couple of years back that makes drawing such custom characters easy. I've used this for both ascii/graphical LCDs - I don't remember if the output was suitable for both or just one or the other.
Lcd Character designer The 'save' button causes the changes made to a character in the top-pane to be written to the 'memory' of the LCD panel and causes the appearance of the currently chosen character to change.
As for the pointer stuff, you seem to be making it considerably more complex than it needs to be.
Here's a quick sample. I dont have access to an arduino this moment, so have used printf instead.
int main()
{
char *stringTable[] = { "string 1", "string two", "string three", NULL };
int i, n = sizeof(stringTable) / sizeof(*stringTable);
for (i=0; i<n-1; i++)
printf("(%d chars): %s\n", strlen(stringTable[i]), stringTable[i]);
printf("-------------\n");
char **curPtr = stringTable;
do
{
printf("%s\n", *curPtr); curPtr++; } while ( *curPtr ); }
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Thanks,
basically you confirmed that I need a pointer to the double dimension array.
That is all I wanted to know.
Cheers
Vaclav
|
|
|
|
|
Why are you using both a sentinel value and the array size (just out of curiosity)?
|
|
|
|