#pragma once

#include <can-jf0815-hw.h>
#include <why-semaphore.h>

#include <string>


class CAN_JF0815
{
public:
    CAN_JF0815(const std::string& can_iface);

    void xmit(const CANFrame&);                        // <-- blocks caller until frame xmitted
    CANFrame recv();                                   // <-- blocks caller until frame received

private:
    CAN_JF0815_HW _controller;    
    Why::Semaphore _sem_xmit_done;
    Why::Semaphore _sem_recv_ready;
    void _isr_xmit_done();
    void _isr_recv_ready();
};
