Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to use constructor list passing an array Pin
Victor Nijegorodov20-Apr-18 6:45
Victor Nijegorodov20-Apr-18 6:45 
GeneralRe: How to use constructor list passing an array Pin
Vaclav_20-Apr-18 8:45
Vaclav_20-Apr-18 8:45 
GeneralRe: How to use constructor list passing an array Pin
Victor Nijegorodov20-Apr-18 11:13
Victor Nijegorodov20-Apr-18 11:13 
GeneralRe: How to use constructor list passing an array Pin
Vaclav_20-Apr-18 11:25
Vaclav_20-Apr-18 11:25 
Questionlinking issue Pin
tasumisra16-Apr-18 6:51
tasumisra16-Apr-18 6:51 
AnswerRe: linking issue Pin
Victor Nijegorodov16-Apr-18 21:39
Victor Nijegorodov16-Apr-18 21:39 
AnswerRe: linking issue Pin
Richard MacCutchan17-Apr-18 0:33
mveRichard MacCutchan17-Apr-18 0:33 
QuestionHow to write more that ONE data byte into ioctl file? Pin
Vaclav_11-Apr-18 14:47
Vaclav_11-Apr-18 14:47 
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>
AnswerRe: How to write more that ONE data byte into ioctl file? Pin
Richard MacCutchan11-Apr-18 21:26
mveRichard MacCutchan11-Apr-18 21:26 
AnswerRe: How to write more that ONE data byte into ioctl file? Pin
Victor Nijegorodov11-Apr-18 22:06
Victor Nijegorodov11-Apr-18 22:06 
AnswerRe: How to write more that ONE data byte into ioctl file? Pin
Jochen Arndt11-Apr-18 22:18
professionalJochen Arndt11-Apr-18 22:18 
GeneralRe: How to write more that ONE data byte into ioctl file? Pin
Vaclav_12-Apr-18 3:57
Vaclav_12-Apr-18 3:57 
Questionapp is not running in debug mode Pin
Member 83893869-Apr-18 20:39
Member 83893869-Apr-18 20:39 
AnswerRe: app is not running in debug mode Pin
Maciej Los9-Apr-18 21:01
mveMaciej Los9-Apr-18 21:01 
AnswerRe: app is not running in debug mode Pin
Victor Nijegorodov9-Apr-18 22:46
Victor Nijegorodov9-Apr-18 22:46 
GeneralRe: app is not running in debug mode Pin
Member 83893869-Apr-18 23:14
Member 83893869-Apr-18 23:14 
GeneralRe: app is not running in debug mode Pin
Victor Nijegorodov10-Apr-18 1:03
Victor Nijegorodov10-Apr-18 1:03 
QuestionInter Process Communication between C++ - C# Pin
ptr_Electron8-Apr-18 18:13
ptr_Electron8-Apr-18 18:13 
AnswerRe: Inter Process Communication between C++ - C# Pin
Jochen Arndt8-Apr-18 21:26
professionalJochen Arndt8-Apr-18 21:26 
AnswerRe: Inter Process Communication between C++ - C# Pin
Randor 9-Apr-18 10:03
professional Randor 9-Apr-18 10:03 
AnswerRe: Inter Process Communication between C++ - C# Pin
jschell14-Apr-18 5:48
jschell14-Apr-18 5:48 
QuestionHow cin.get() works in loop ? Pin
Tarun Jha7-Apr-18 3:32
Tarun Jha7-Apr-18 3:32 
SuggestionRe: How cin.get() works in loop ? Pin
David Crow7-Apr-18 6:34
David Crow7-Apr-18 6:34 
AnswerRe: How cin.get() works in loop ? Pin
Richard MacCutchan7-Apr-18 20:55
mveRichard MacCutchan7-Apr-18 20:55 
AnswerRe: How cin.get() works in loop ? Pin
Peter_in_27808-Apr-18 21:13
professionalPeter_in_27808-Apr-18 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.