|
|
@ -0,0 +1,63 @@ |
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "zlinuxcomponents/zmainhelper.hpp"
|
|
|
|
//
|
|
|
|
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
|
|
|
|
#include "iflytopcpp/core/thread/thread.hpp"
|
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <linux/can.h>
|
|
|
|
#include <linux/can/raw.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "zlinuxcomponents/i2c/i2c_bus.hpp"
|
|
|
|
#include "zlinuxcomponents/i2c/m24lr64e.hpp"
|
|
|
|
|
|
|
|
using namespace iflytop; |
|
|
|
using namespace core; |
|
|
|
using namespace std; |
|
|
|
using namespace clipp; |
|
|
|
|
|
|
|
/***********************************************************************/ |
|
|
|
/***********************************************************************/ |
|
|
|
/***********************************************************************/ |
|
|
|
/***********************************************************************/ |
|
|
|
class Main { |
|
|
|
ENABLE_LOGGER(Main); |
|
|
|
unique_ptr<Thread> thread; |
|
|
|
|
|
|
|
shared_ptr<I2CBus> m_i2c_bus = nullptr; |
|
|
|
shared_ptr<M24LR64E> m_m24lr64e = nullptr; |
|
|
|
|
|
|
|
public: |
|
|
|
Main(/* args */) {} |
|
|
|
~Main() {} |
|
|
|
void run(int argc, char* argv[]) { |
|
|
|
thread.reset(new Thread("main", [&]() { exit(main(argc, argv)); })); |
|
|
|
while (true) sleep(1000); |
|
|
|
} |
|
|
|
void onSIGINT() { exit(0); } |
|
|
|
int main(int argCount, char* argValues[]) { //
|
|
|
|
m_i2c_bus.reset(new I2CBus()); |
|
|
|
m_m24lr64e.reset(new M24LR64E()); |
|
|
|
|
|
|
|
m_i2c_bus->open("/dev/i2c-1"); |
|
|
|
m_m24lr64e->initialize(m_i2c_bus); |
|
|
|
|
|
|
|
m_m24lr64e->dump_eeprom(); |
|
|
|
logger->info("dump eeprom done"); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
}; |
|
|
|
MAIN_ENTRY(); |
|
|
|
// ip link set can0 down
|
|
|
|
// ip link set can0 type can bitrate 500000
|
|
|
|
// ip link set can0 up
|