??? 04/16/08 17:11 Modified: 04/16/08 17:17 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#153527 - Stop now, before you make things worse! Responding to: ???'s previous message |
Russ said:
What is in 'byValue1' and 'byValue2' when this statement is executed?
Please explain what the statement does, and what you expect to find in 'byValue' after it has executed. Chris said:
Since I was getting "can not add two pointers together", what I've done was assign byValue1 and byValue2 as a place holder for each array member 0 and 1 then then conconetate the two byValues together to "build" the device in hex.
So for example you type 2 in the edit box, its captured, converted to hex, stored in byValue1, type 3, its captured, converted to hex, stored in byValue2, and then "device" is the concanotation of the two byValues together, and that device "byte" is sent via I2C to communicated with the slave MPU, ADC, and EEPROM in hardware. It was really just a way to get around the pointer errors that I wasn't sure how to get running properly. Chris, I don't mean to be offensive in any way, but it's evident from the code you posted earlier and from your answer above that you are not even remotely competent as a C/C++ programmer. Here's your code again, with some line numbers added for ease of reference: 1 void CHC_controllerDlg::OnChangeDevice() 2 { 3 UpdateData(TRUE); 4 byte byReadData[2]; 5 for (int i = 0; i < 1; i++) 6 { 7 byReadData[0] = (byte)strtoul( m_strDeviceAddress, NULL, 16 ) 8 byReadData[0] = ("%x", byReadData[0]); 9 } 10 11 for (i = 0; i < 1; i++) 12 { 13 byReadData[1] = (byte)strtoul( m_strDeviceAddress, NULL, 16 ) 14 byReadData[1] = ("%x", byReadData[1]); 15 } 16 17 byte byValue1 = byReadData[0]; 18 byte byValue2 = byReadData[1]; 19 20 byte byValue = (byValue2) & (byValue1) ; 21 22 device = byValue; 23 m_strDeviceAddress.Empty(); 24 m_strDeviceAddress.Format("0x", byValue1); 25 byte temp = (byte)strtoul( m_strDeviceAddress, NULL, 16 ) 26 m_strDeviceAddress.FormatMessage("%x", byValue2); 27 28 allset |=0x8; 29 UpdateData(FALSE); 30 }This code is flawed in multiple ways:
-- Russ |
Topic | Author | Date |
C++, 8051, cleaning up a mess......need advise | 01/01/70 00:00 | |
Trying to convert after typing is too hard | 01/01/70 00:00 | |
Take a look here... | 01/01/70 00:00 | |
I gave that a run, | 01/01/70 00:00 | |
Maybe this will help | 01/01/70 00:00 | |
Thanks Russ, some thoughts | 01/01/70 00:00 | |
More thoughts | 01/01/70 00:00 | |
Your right, you know how it is | 01/01/70 00:00 | |
Is this it? | 01/01/70 00:00 | |
Well, no | 01/01/70 00:00 | |
Hopefully I can answer this correctly | 01/01/70 00:00 | |
Is Prosise onlin? | 01/01/70 00:00 | |
Emailed link to you | 01/01/70 00:00 | |
Two more questions | 01/01/70 00:00 | |
Placeholders for array data | 01/01/70 00:00 | |
Stop now, before you make things worse! | 01/01/70 00:00 | |
No offense taken at all | 01/01/70 00:00 | |
I got the link | 01/01/70 00:00 |