@@ -932,6 +932,51 @@ bool Connection::test(std::uint_fast16_t commonAddress, bool with_time,
932932 return result;
933933}
934934
935+ bool Connection::requestDirectory (std::uint_fast16_t commonAddress,
936+ std::uint_fast32_t ioa,
937+ const bool wait_for_response) {
938+ Module::ScopedGilRelease const scoped (" Connection.requestDirectory" );
939+
940+ if (!isOpen ())
941+ return false ;
942+
943+ std::string const cmdId =
944+ std::to_string (commonAddress) + " -F_SC_NA_1-" + std::to_string (ioa);
945+ if (wait_for_response) {
946+ prepareCommandSuccess (cmdId, COMMAND_AWAIT_CON_TERM );
947+ }
948+
949+ // Create ASDU for directory request (F_SC_NA_1, Type 122)
950+ std::unique_lock<Module::GilAwareMutex> lock (connection_mutex);
951+ CS101_AppLayerParameters alParams =
952+ CS104_Connection_getAppLayerParameters (connection);
953+
954+ CS101_ASDU asdu =
955+ CS101_ASDU_create (alParams, false , CS101_COT_FILE_TRANSFER , 0 ,
956+ static_cast <int >(commonAddress), false , false );
957+
958+ // Create FileCallOrSelect information object
959+ // SCQ = 0 means "select directory"
960+ FileCallOrSelect io =
961+ FileCallOrSelect_create (NULL , static_cast <int >(ioa), 0 , 0 , 0 );
962+
963+ CS101_ASDU_addInformationObject (asdu, (InformationObject)io);
964+ InformationObject_destroy ((InformationObject)io);
965+
966+ bool const result = CS104_Connection_sendASDU (connection, asdu);
967+ lock.unlock ();
968+
969+ CS101_ASDU_destroy (asdu);
970+
971+ if (wait_for_response) {
972+ if (result) {
973+ return awaitCommandSuccess (cmdId);
974+ }
975+ cancelCommandSuccess (cmdId);
976+ }
977+ return result;
978+ }
979+
935980bool Connection::transmit (std::shared_ptr<Object::DataPoint> point,
936981 const CS101_CauseOfTransmission cause) {
937982 auto type = point->getType ();
0 commit comments