libais icon indicating copy to clipboard operation
libais copied to clipboard

"currents" list attached in wrong place

Open andyvan-trabus opened this issue 3 years ago • 0 comments

I see the following code in ais_py.cpp:

case AIS8_1_26_SENSOR_CURR_2D: { Ais8_1_26_Curr2D *rpt = reinterpret_cast<Ais8_1_26_Curr2D *>(msg.reports[rpt_num]); DictSafeSetItem(rpt_dict, "type", rpt->type); DictSafeSetItem(rpt_dict, "spare", rpt->spare);

    PyObject *curr_list = PyList_New(3);
    DictSafeSetItem(dict, "currents", curr_list);
    for (size_t idx = 0; idx < 3; idx++) {
      PyObject *curr_dict = PyDict_New();
      DictSafeSetItem(curr_dict, "speed", rpt->currents[idx].speed);
      DictSafeSetItem(curr_dict, "dir", rpt->currents[idx].dir);
      DictSafeSetItem(curr_dict, "depth", rpt->currents[idx].depth);
      PyList_SetItem(curr_list, idx, curr_dict);
    }
  }
  break;

The DictSafeSetItem call for "currents" should be specifying rpt as the first parameter, not dict. This same problem is present in the code for AIS8_1_26_SENSOR_HORZ_FLOW and AIS8_1_26_SENSOR_CURR_3D.

andyvan-trabus avatar Sep 10 '21 00:09 andyvan-trabus