|
This may be too silly to ask here , really a hardware question , but I am stuck.
I am using ioctl to write to I2C device - LCM1602.
This device uses PCF8574 "I2C interface chip" to connect to HD44780 Hitachi LCD controller in <b>4 bits mode</b> .
Setting the HD447890 into 4 bit mode is well documented, but..
After the HD44780 is set into 4 bit mode further configuration need to be set using TWO (I2C sends 8 bits but only 4 bits are valid ) data "packets" after the single I2C address is send.
I have this single address plus data working and cannot figure out HOW to
add another "buffer" so I can send TWO 8 bits words.
The I2C spec requires to wait for ACK after the first 8 bit data is send, so I just cannot add the data into single buffer.
PLEASE - THE ATTACHED CODE IS WORK IN PROGRESS, REDUNDANT ETC , BUT IT WORKS!
ANY INAPPROPRIATE COMMENTS ON IT WILL BE IGNORED AND ARE NOT WELCOMED.
However, I'll appreciate any suggestions on how to send
ONE address byte and multiple data bytes in I2C format.
Thanks.
<pre lang="c++">
// original expanded
// write directly to expander using ioctl file descriptor
// and plain write(fd,data,#)
// parameters
// int file file descriptor
// char data data to write
// int NumberOfCharacters to write
// return 0 when actual # of characters match NumberOfCharacters
int CLASS_LCM1602::expanderWrite(
int file,
char data,
int NumberOfCharacters) {
#ifdef DEBUG
//cout << "\033[1;31mint C_I2C::TestFunction(int a)\033[0m\n";
cout << "*** TRACE file " << __FILE__ << endl;
cout << " Enhanced function " << __FUNCTION__ << endl;
cout << " line " << __LINE__ << endl;
#endif
int NumberOfCharactersWritten;
// why NOBACKLIGHT during initialization - too fast to see anyway (?)
char buffer = data; // | LCD_BACKLIGHT;
//buffer = 0;
//while (1)
{
#ifdef DEBUG
cout << " buffer cast " << (static_cast<int>(buffer) & 0xFF) << endl;
cout << " buffer HEX cast " << hex << buffer << endl;
cout << " buffer + " << hex << +buffer << endl;
cout << " function " << __FUNCTION__ << endl;
cout << " line " << __LINE__ << endl;
#endif
//sleep(5);
}
// <b>NumberOfCharacters defaults to 1</b>
NumberOfCharactersWritten = write(file, &buffer, NumberOfCharacters);
// check characters written
if (NumberOfCharacters == NumberOfCharactersWritten) {
#ifdef DEBUG
cout << "Success NumberOfCharacters written " << NumberOfCharacters
<< endl;
#endif
//exit(1);
return 0;
} else {
cout << "\033[1;31mFailed expanderWrite\033[0m\n"; // failed
return -1;
}
}
</pre>
|
|
|
|
|
Vaclav_ wrote: ANY INAPPROPRIATE COMMENTS ON IT WILL BE IGNORED AND ARE NOT WELCOMED. Well that really encourages people to want to help you.
|
|
|
|
|
Vaclav_ wrote:
PLEASE - THE ATTACHED CODE IS WORK IN PROGRESS, REDUNDANT ETC , BUT IT WORKS!
ANY INAPPROPRIATE COMMENTS ON IT WILL BE IGNORED AND ARE NOT WELCOMED.
Hmm,
don't you mind such a "thesis" together with unformatted code looks like gross unrespect to guys you ask to help?
|
|
|
|
|
You do it like with any write operation to a file descriptor by passing a buffer and it's size:
char buf[2];
buf[0] = data & 0x0f;
buf[1] = data >> 4;
write(file, buf, 2);
|
|
|
|
|
|
Hello,
My 64 bit (VS 2013)application is not running in debug mode. Output log is:
"'
MainApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120d.dll'. Cannot find or open the PDB file.
'MainApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120d.dll'. Cannot find or open the PDB file.
'MainApp.exe' (Win32): Unloaded 'C:\Windows\System32\msvcp120d.dll'
'MainApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcr120d.dll'. Cannot find or open the PDB file.
The thread 0x1bc8 has exited with code -1073741701 (0xc000007b).
The thread 0x2964 has exited with code -1073741701 (0xc000007b).
The thread 0x1040 has exited with code -1073741701 (0xc000007b).
The program '[9944] MainApp.exe' has exited with code -1073741701 (0xc000007b).
"
I tried to look over internet but could not find relevant answer. Can you please help to resolve it?
|
|
|
|
|
Check this: 0xc000007b error
They say that your settings or setup got messed up and:
Quote: I would suggest 2 things: first, try to reset your settings from Tools->import and export settings -> Reset all settings-> reset all settings, overwriting current settings.
If after that it still does not work, I would repair/re-install VS.
|
|
|
|
|
Did you by chance mixed some native and managed parameter options?
|
|
|
|
|
may be....where is this option?
|
|
|
|
|
Well, after re reading your OP I'm afraid I was wrong with my "hint".
It seems to more probable the reason is in a mixing some 32/64 bit settings or linked DLLs.
BTW, doe the Release 64 build work?
And Debug 32 build?
|
|
|
|
|
I am working on C++ project where performance is critical. there is no logging mechanism. I dont want to implement logging in the same project as it will hit performance. And hence I want to create A C# project while takes care of actually logging from C++ process I will push the Log strings to C# process to do Actually logging.
I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket
Which should not hit the performance
Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
|
|
|
|
|
Logging will not be a performance issue if you do that in an own thread. That thread may be part of the application itself or another application.
Using another application with IPC makes it more complicated and requires that the other application is running. So I would not use another application if there is no need for other communications besides logging.
There might be even no need of using a thread when logging does not occur at high rates with large data. The log data has to be prepared anyway within the time critical thread. Using then a log file which stays open might be sufficient. If you are concerned about the file write times, use overlapped IO so that the writing is done by the system in the background (which is basically the same as suggested above: moving the operation to another thread).
I know that the above is not what you asked for but I think it is helpful and you might find out that using IPC is not necessary. When maximum performance is a must-have, you have to use one of the above mentioned methods (own thread or overlapped IO) anyway even with IPC.
|
|
|
|
|
ptr_Electron wrote: I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket
Which should not hit the performance
On the Microsoft Windows platform the fastest possible logging is through Event Tracing for Windows (ETW)[^]. Logging with ETW so fast... graphics drivers can render at 150 FPS and perform logging at the same time without losing any framerate.
What it basically does is write integers into a circular buffer all in RAM. There is nothing faster.
ptr_Electron wrote: Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
ETW logging msdn examples - Bing[^]
Best Wishes,
-David Delaune
|
|
|
|
|
ptr_Electron wrote: I dont want to implement logging in the same project as it will hit performance.
I was involved in a C++ project years ago. Unix based. Performance was a contractual requirement.
The architect was sure that logging was a performance problem.
So we removed logging.
Absolute zero impact on performance.
And that was back when spewing stuff to a console (stdio) could impact performance.
If you have a performance problem then you need to address the requirements and design first before looking for problems in the implementation and technologies.
ptr_Electron wrote: which has the mechanism to Log from C++ to C# code please
Every logging library that I have seen for at least the past 10 years if not longer uses pluggable designs. Which means if the plugs that are already available do not meet your needs then you can create your own. However at least when I looked some already supported remote logging plugs.
|
|
|
|
|
#include <iostream>
using namespace std;
int main(){
char c;
cin.get(c);
while(c != '\n'){
cout << c ;
cin.get(c);
}
}
int the code above shouldn't cout << c print every charecter i put in cin.get() in loop ?
Quote: while(c != '\n'){
cout << c ; //displays the charecter on screen
cin.get(c); //get another charecter
}
instead it print the string i enter collectively, for ex.
Quote:
input : "Jhon simon"
output : "Jhon simon"
please explain
Thank you
|
|
|
|
|
Your explanation is a bit unclear. If the "input:" and "output:" are the same, what exactly is the issue?
With limited information, the only thing I can suggest is:
cout << c << std::flush;
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
No, it prints each character as you type it.
|
|
|
|
|
Google "cout buffering" for an explanation.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
cin.get() does not read individual keystrokes -- the input is buffered by the terminal until you hit Enter, then all of the input is sent to the program at once.
To read individual keystrokes, you'll have to rely on a third-party tool like GNU's ncurses library.
|
|
|
|
|
I use the CListCtrl to display a list of grouped properties. Each of these groups should be described by an explanatory text. That's why I entered longer texts as subtitles for the groups.
If the subtitle is short enough that it fits in one line, then everything looks fine.
However, if the subtitle is longer than one line, it is wrapped at the width of the list control. Unfortunately, the wrapped lines are then superimposed by the following contents of the list.
For example, the content of the items of the group overwrite the wrapped subtitle. When the group is collapsed, the subtitle is superimposed by the following groups.
See also the examples in the following Screenshot:
- Group 1 has a short subtitle and all looks fine.
- Group 2 has a log subtitle, which is overwritten by the contents of the items.
- Group 3 is collapsed and the wrapped subtitle is overwritten by the content of group 4.
Is there a way to expand the area for the subtitles?
Regards,
Friedbert
|
|
|
|
|
How can I do this in a smarter way in regular C-programming, without having an init function that initializes the values?
struct myStruct_s {
int myInt;
Bool_t myBool;
EventCallback_t myEventCallback;
};
#define DESIRED_ARRAY_SIZE (5)
static struct myStruct_s myArray[] = {
#if 1 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 2 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 3 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 4 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 5 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 6 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 7 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 8 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 9 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 10 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 11 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 12 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 13 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 14 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 15 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 16 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 17 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 18 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 19 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
#if 20 <= DESIRED_ARRAY_SIZE
{0xABCD, TRUE, NULL},
#endif
};
modified 6-Apr-18 7:29am.
|
|
|
|
|
Please edit the above, and remove all that formatting. People here can read normal font sizes quite well.
|
|
|
|
|
I didn't use any formatting. The forum has a bug, it does weird things to the formatting if you start a line with either #define of #if (try for yourself).
|
|
|
|
|
If you know HTML and want to insert HTML tags manually when posting (besides using the options on top of the editor window) have a look at the bottom of the page when posting a message. There are two options:
"Treat my content as plain text, not as HTML"
and
"Use Markdown formatting"
When both are unchecked nothing will be auto formatted.
The first option can be also changed on your profile settings page in the Forums tab.
|
|
|
|
|
|