Skip to content

Func did for i2c#290

Open
Wiktor-Laska wants to merge 5 commits into
masterfrom
func-did-for-i2c
Open

Func did for i2c#290
Wiktor-Laska wants to merge 5 commits into
masterfrom
func-did-for-i2c

Conversation

@Wiktor-Laska
Copy link
Copy Markdown
Contributor

funkcje did read, wirte dla zadania #214

@Wiktor-Laska Wiktor-Laska requested a review from a team as a code owner January 13, 2026 18:38
Copy link
Copy Markdown
Collaborator

@Mateusz-Krajewski Mateusz-Krajewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strasznie dużo niespójności, kody błędów są losowe, czasami błędy zwracają brak błędu. Brak zachowanej konwencji plików .h .cpp ? i2c_mw_read ma .h i .cpp a i2c_mw_write ma tylko .h ??? Nie zaimplementowano wszystkich funkcjonalności oraz zepsuto funkcjonalność i2c_service. Dodatkowo jest konflikt repozytorium system_definitions

}

} // namespace mw
} // namespace srp No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} // namespace srp
} // namespace srp

Comment on lines +20 to +22
ara::core::Result<ara::diag::OperationOutput> Read() noexcept override {
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kRequestOutOfRange);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ara::core::Result<ara::diag::OperationOutput> Read() noexcept override {
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kRequestOutOfRange);
}
ara::core::Result<ara::diag::OperationOutput> Read() noexcept override;

Comment on lines +11 to +31
ara::core::Result<void> I2CMWREAD::Write(const std::vector<uint8_t> &payload) noexcept {
if (payload.size() < 3 || !payload.size()%2) {
ara::log::LogInfo() << "Wrong payload size: " << payload.size();
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kSubFunctionNotSupported);
}
if (this->i2c_->Ioctl(payload[0]) != core::ErrorCode::kOk) {
ara::log::LogInfo() << "Wrong Input for payload i2c read";
return {};
}

ara::log::LogInfo() << "Receive diag write req, calling I2CService::WriteRead";
std::vector<uint8_t> vec(payload.begin() + 1, payload.end());
auto result = i2c_service_->WriteRead(vec, nullptr);

if (result == std::nullopt) {
ara::log::LogInfo() << "Wrong Input for i2c WriteRead";
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kConditionsNotCorrect);
}

return {};
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I jak mam odczytać co zwróciła funkcja? chyba metoda read powinna zwracac wynik ostatniej operacji?

ara::core::Result<void> I2CMWREAD::Write(const std::vector<uint8_t> &payload) noexcept {
if (payload.size() < 3 || !payload.size()%2) {
ara::log::LogInfo() << "Wrong payload size: " << payload.size();
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kSubFunctionNotSupported);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kSubFunctionNotSupported);
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kInvalidMessageLengthFormat);

}
if (this->i2c_->Ioctl(payload[0]) != core::ErrorCode::kOk) {
ara::log::LogInfo() << "Wrong Input for payload i2c read";
return {};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return {};
return ara::diag::MakeErrorCode(ara::diag::UdsDiagErrc::kRequestSequenceError);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten błąd tyczy się sytułacji ze w zlej kolejnosci przysyłasz dane powinien być bład o długości zapytania jest takie

if (this->i2c_->Write(vec) == core::ErrorCode::kOk) {
ara::log::LogInfo() << "Wrong Input for i2c Write";
return ara::diag::MakeErrorCode(
ara::diag::UdsDiagErrc::kSubFunctionNotSupported);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? CHATGPT PLS GIVE ME RANDOM ERROR CODE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

użyłem błędu z funkcji wyżej "by działało" co podałeś

I2CService::I2CService():
i2c_logger_(ara::log::LoggingMenager::GetInstance()->CreateLogger("i2c", "", ara::log::LogLevel::kInfo)) {}

i2c_logger_(ara::log::LoggingMenager::GetInstance()->CreateLogger("i2c", "", ara::log::LogLevel::kInfo)),did_instance("/srp/mw/i2cMWService/i2c_Write_did"), read_instance("/srp/mw/i2cMWService/i2c_Read_did") {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
i2c_logger_(ara::log::LoggingMenager::GetInstance()->CreateLogger("i2c", "", ara::log::LogLevel::kInfo)),did_instance("/srp/mw/i2cMWService/i2c_Write_did"), read_instance("/srp/mw/i2cMWService/i2c_Read_did") {}
i2c_logger_(ara::log::LoggingMenager::GetInstance()->CreateLogger("i2c", "", ara::log::LogLevel::kInfo)), did_instance(I2C_WRITE_DID_INSTANCE ), read_instance(I2C_READ_DID_INSTANCE) {}

@@ -22,8 +22,7 @@ namespace {
const constexpr char* I2C_IPC_ADDR = "SRP.I2C";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const constexpr char* I2C_IPC_ADDR = "SRP.I2C";
const constexpr char* I2C_IPC_ADDR = "SRP.I2C";
constexpr auto I2C_WRITE_DID_INSTANCE = "/srp/mw/i2cMWService/i2c_Write_did";
constexpr auto I2C_READ_DID_INSTANCE = "/srp/mw/i2cMWService/i2c_Read_did";

return std::nullopt;
}
return i2c_->ReadWrite(payload[0], payload[1]);
return i2c_->ReadWrite(payload[0]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

czemu? psuje to chyba wszystkie drivery do i2c.

Suggested change
return i2c_->ReadWrite(payload[0]);
return i2c_->ReadWrite(payload[0], payload[1]);

const std::shared_ptr<srp::i2c::Header> headerPtr,
std::optional<std::vector<uint8_t>> payload);

friend class I2CMWREAD;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie prościej było używać i2c_controllera?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

możliwe, choć nie wiedziałem że jest taka opcja

@Mateusz-Krajewski Mateusz-Krajewski force-pushed the func-did-for-i2c branch 2 times, most recently from d6bbd80 to 289281b Compare January 15, 2026 12:25
@Mateusz-Krajewski
Copy link
Copy Markdown
Collaborator

Dodatkowo jak widać już sam cpplint się wywala.
Kusi zacytować klasyka: https://youtu.be/CvarySY_6Ic?si=4huUu9sPOOmwdL6Z

@Mateusz-Krajewski Mateusz-Krajewski linked an issue Jan 15, 2026 that may be closed by this pull request
2 tasks
@Wiktor-Laska
Copy link
Copy Markdown
Contributor Author

Strasznie dużo niespójności, kody błędów są losowe, czasami błędy zwracają brak błędu. Brak zachowanej konwencji plików .h .cpp ? i2c_mw_read ma .h i .cpp a i2c_mw_write ma tylko .h ??? Nie zaimplementowano wszystkich funkcjonalności oraz zepsuto funkcjonalność i2c_service. Dodatkowo jest konflikt repozytorium system_definitions

Comment thread deployment/mw/i2c/BUILD
Comment on lines +7 to +8
"//deployment/system_definition/diag/jobs/i2c_service/i2c_write:i2c_Write_job",
"//deployment/system_definition/diag/jobs/i2c_service/i2c_read:i2c_Read_job",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIe żeby coś ale DiD natywnie wspiera write i read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write DID/RID for i2c_mw

3 participants