# Path: can4python/exceptions.py
# class CanException(Exception):
# class CanTimeoutException(CanException):
# class CanNotFoundByKernelException(CanException):
# 
# Path: can4python/canframe.py
# class CanFrame():
#     def __init__(self, frame_id, frame_data, frame_format=constants.CAN_FRAMEFORMAT_STANDARD):
#     def __repr__(self):
#     def __len__(self):
#     def from_empty_bytes(cls, frame_id, number_of_bytes, frame_format=constants.CAN_FRAMEFORMAT_STANDARD):
#     def from_rawframe(cls, rawframe):
#     def frame_id(self):
#     def frame_id(self, value):
#     def frame_data(self):
#     def frame_data(self, value):
#     def frame_format(self):
#     def frame_format(self, value):
#     def get_signalvalue(self, signaldefinition):
#     def set_signalvalue(self, signaldefinition, physical_value=None):
#     def unpack(self, frame_definitions):
#     def get_rawframe(self):
#     def get_descriptive_ascii_art(self):
# 
# Path: can4python/caninterface_raw.py
# class SocketCanRawInterface():
#     def __init__(self, interfacename, timeout=None):
#     def __repr__(self):
#     def interfacename(self):
#     def close(self):
#     def recv_next_frame(self):
#     def send_frame(self, input_frame):
#     def set_receive_filters(self, framenumbers):


import subprocess
import sys
import time
import unittest
from can4python import exceptions
from can4python import canframe
from can4python import caninterface_raw
        self.assertRaises(exceptions.CanException, self.interface.recv_next_frame)

    def testReceiveClosedInterface(self):
        self.interface.close()
        self.assertRaises(exceptions.CanException, self.interface.recv_next_frame)

    # Send #

    def testSend(self):

        self.simulated_can_process = subprocess.Popen(['candump', VIRTUAL_CAN_BUS_NAME, '-n', '1'], shell=False,
                                                      universal_newlines=True,
                                                      stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        time.sleep(0.1)
        frame = canframe.CanFrame.from_empty_bytes(self.FRAME_ID_SEND, self.FRAME_NUMBER_OF_DATABYTES)
        self.interface.send_frame(frame)

        print("\nWaiting for testfile to send_frame CAN frame ")
        out, err = self.simulated_can_process.communicate()
        print("Confirmed CAN frame")

        known_result = "[8]  00 00 00 00 00 00 00 00"
        self.assertIn(known_result, out)

    def testSendClosedBus(self):
        disable_virtual_can_bus()
        frame = canframe.CanFrame.from_empty_bytes(self.FRAME_ID_SEND, self.FRAME_NUMBER_OF_DATABYTES)
        self.assertRaises(exceptions.CanException, self.interface.send_frame, frame)

    def testSendClosedInterface(self):

# Path: can4python/exceptions.py
# class CanException(Exception):
# class CanTimeoutException(CanException):
# class CanNotFoundByKernelException(CanException):
# 
# Path: can4python/canframe.py
# class CanFrame():
#     def __init__(self, frame_id, frame_data, frame_format=constants.CAN_FRAMEFORMAT_STANDARD):
#     def __repr__(self):
#     def __len__(self):
#     def from_empty_bytes(cls, frame_id, number_of_bytes, frame_format=constants.CAN_FRAMEFORMAT_STANDARD):
#     def from_rawframe(cls, rawframe):
#     def frame_id(self):
#     def frame_id(self, value):
#     def frame_data(self):
#     def frame_data(self, value):
#     def frame_format(self):
#     def frame_format(self, value):
#     def get_signalvalue(self, signaldefinition):
#     def set_signalvalue(self, signaldefinition, physical_value=None):
#     def unpack(self, frame_definitions):
#     def get_rawframe(self):
#     def get_descriptive_ascii_art(self):
# 
# Path: can4python/caninterface_raw.py
# class SocketCanRawInterface():
#     def __init__(self, interfacename, timeout=None):
#     def __repr__(self):
#     def interfacename(self):
#     def close(self):
#     def recv_next_frame(self):
#     def send_frame(self, input_frame):
#     def set_receive_filters(self, framenumbers):


# Path: tests/test_caninterface_raw.py
import subprocess
import sys
import time
import unittest
from can4python import exceptions
from can4python import canframe
from can4python import caninterface_raw

        self.assertRaises(exceptions.CanException, self.interface.recv_next_frame)

    def testReceiveClosedInterface(self):
        self.interface.close()
        self.assertRaises(exceptions.CanException, self.interface.recv_next_frame)

    # Send #

    def testSend(self):

        self.simulated_can_process = subprocess.Popen(['candump', VIRTUAL_CAN_BUS_NAME, '-n', '1'], shell=False,
                                                      universal_newlines=True,
                                                      stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        time.sleep(0.1)
        frame = canframe.CanFrame.from_empty_bytes(self.FRAME_ID_SEND, self.FRAME_NUMBER_OF_DATABYTES)
        self.interface.send_frame(frame)

        print("\nWaiting for testfile to send_frame CAN frame ")
        out, err = self.simulated_can_process.communicate()
        print("Confirmed CAN frame")

        known_result = "[8]  00 00 00 00 00 00 00 00"
        self.assertIn(known_result, out)

    def testSendClosedBus(self):
        disable_virtual_can_bus()
        frame = canframe.CanFrame.from_empty_bytes(self.FRAME_ID_SEND, self.FRAME_NUMBER_OF_DATABYTES)
        self.assertRaises(exceptions.CanException, self.interface.send_frame, frame)

    def testSendClosedInterface(self):

        frame = canframe.CanFrame.from_empty_bytes(self.FRAME_ID_SEND, self.FRAME_NUMBER_OF_DATABYTES)