Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding EL6001 fastcat device library #90

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added el6001 device skeleton
davidinkyu-kim committed Mar 20, 2023
commit 9b48f8c15f4a71f2e6e66d0e5dfc2778db19a2bb
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -54,7 +54,8 @@ find_package(YamlCpp REQUIRED 0.6.3)
include(FetchContent)
FetchContent_Declare(jsd
GIT_REPOSITORY https://github.com/nasa-jpl/jsd.git
GIT_TAG v2.1.2
#GIT_TAG v2.1.2
GIT_TAG davkim-add-el6001
Comment on lines +57 to +58
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be addressed before we can conclude this merge.

)
FetchContent_MakeAvailable(jsd)

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ add_library(fastcat STATIC
jsd/el3104.cc
jsd/el3202.cc
jsd/el3318.cc
jsd/el6001.cc
jsd/ild1900.cc
jsd/jed0101.cc
jsd/jed0200.cc
7 changes: 7 additions & 0 deletions src/fcgen/fastcat_types.yaml
Original file line number Diff line number Diff line change
@@ -368,6 +368,13 @@ states:
- name: adc_value_ch8
type: int16_t

- name: el6001
fields:
- name: statusword
type: uint16_t
- name: controlword
type: uint16_t

- name: ild1900
fields:
- name: distance_m
53 changes: 53 additions & 0 deletions src/jsd/el6001.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Include related header (for cc files)
#include "fastcat/jsd/el6001.h"

// Include c then c++ libraries
#include <string.h>

#include <cmath>
#include <iostream>

// Include external then project includes
#include "fastcat/yaml_parser.h"

fastcat::El6001::El6001()
{
MSG_DEBUG("Constructed El6001");

state_ = std::make_shared<DeviceState>();
state_->type = EL6001_STATE;
}

bool fastcat::El6001::ConfigFromYaml(YAML::Node node)
{
bool retval = ConfigFromYamlCommon(node);
jsd_set_slave_config((jsd_t*)context_, slave_id_, jsd_slave_config_);
return retval;
}

bool fastcat::El6001::ConfigFromYamlCommon(YAML::Node node)
{
if (!ParseVal(node, "name", name_)) {
return false;
}
state_->name = name_;

jsd_slave_config_.configuration_active = true;
jsd_slave_config_.product_code = JSD_EL6001_PRODUCT_CODE;
snprintf(jsd_slave_config_.name, JSD_NAME_LEN, "%s", name_.c_str());

return true;
}

bool fastcat::El6001::Read()
{
jsd_el6001_read((jsd_t*)context_, slave_id_);

const jsd_el6001_state_t* jsd_state =
jsd_el6001_get_state((jsd_t*)context_, slave_id_);

state_->el6001_state.statusword = jsd_state->statusword;
state_->el6001_state.controlword = jsd_state->controlword_user;

return true;
}
34 changes: 34 additions & 0 deletions src/jsd/el6001.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef FASTCAT_EL6001_H_
#define FASTCAT_EL6001_H_

// Include related header (for cc files)

// Include c then c++ libraries

// Include external then project includes
#include "fastcat/jsd/jsd_device_base.h"
#include "jsd/jsd_el6001_pub.h"

namespace fastcat
{
class El6001 : public JsdDeviceBase
{
public:
El6001();
bool ConfigFromYaml(YAML::Node node) override;
bool Read() override;
bool Write(DeviceCmd& cmd) override;
// FaultType Process() override;
// void Fault() override;
// void Reset() override;

protected:
bool ConfigFromYamlCommon(YAML::Node node);

private:
jsd_slave_config_t jsd_slave_config_{0};
};

} // namespace fastcat

#endif