![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Gets messages form the pc and translates it to I2C and back.
Dependencies: DevInterfaces I2Cinterfaces MCP4725 mbed
Diff: main.cpp
- Revision:
- 1:8ba039abd9b8
- Parent:
- 0:b40341017545
- Child:
- 2:2330ad8b1baa
--- a/main.cpp Wed May 18 11:22:41 2016 +0000 +++ b/main.cpp Wed May 18 11:35:45 2016 +0000 @@ -61,41 +61,41 @@ bled = 1.0f; // Translate the raw message - Translator::MessageInfo info/* = reader.LastMessageInfo()*/; - if (!Translator::Translate(reader.GetLastMessage(), reader.GetLastMessageSize(), &info)) { - printf("I have failed you..."); - continue; - } + Translator::MessageInfo info = reader.GetLastMessageInfo(); + //if (!Translator::Translate(reader.GetLastMessage(), reader.GetLastMessageSize(), &info)) { + // printf("I have failed you..."); + // continue; + //} int dacValue; if (info.IsRead()) { // If read command - printf("Reading "); + //printf("Reading "); // Read the current DAC value if (dac.getDACvalue(dacValue) == 0) { - printf("succes!"); + //printf("succes!"); // Succesful: send back the current DAC value Writer::Send(info, dacValue); } else { - printf("failed"); + //printf("failed"); // Failed: send error message Writer::SendError(info); } } else if (info.IsWrite()) { // If write command - printf("Writing "); + //printf("Writing "); // Set the given DAC value if (dac.setDACvalue(info.DacValue) == 0) { - printf("succes!"); + //printf("succes!"); // Succesful: Get the DAC value dac.getDACvalue(dacValue); // Send new value Writer::Send(info, dacValue); } else { - printf("failed"); + //printf("failed"); // Failed: send error message Writer::SendError(info); } } else if (info.IsOption()) { - printf("Option failed"); + //printf("Option failed"); // Not implemented yet Writer::SendError(info); }