Skip to content

Commit

Permalink
Configure the code to work with firmware v15
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Nov 3, 2017
1 parent ab0ddd7 commit b8850ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
11 changes: 6 additions & 5 deletions pybpodapi/bpod/bpod_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class BpodBase(object):
CHECK_STATE_MACHINE_COUNTER = 0

def __init__(self, serial_port=None, sync_channel=None, sync_mode=None):

self._session = self.create_session()

self.serial_port = serial_port if serial_port is not None else settings.SERIAL_PORT
self.baudrate = settings.BAUDRATE
self.sync_channel = sync_channel if sync_channel is not None else settings.SYNC_CHANNEL
Expand All @@ -56,8 +57,6 @@ def __init__(self, serial_port=None, sync_channel=None, sync_mode=None):
self._hardware.sync_channel = self.sync_channel # 255 = no sync, otherwise set to a hardware channel number
self._hardware.sync_mode = self.sync_mode # 0 = flip logic every trial, 1 = every state

if not hasattr(self, '_session'): self._session = Session()

self.session += SessionInfo( self.session.INFO_SERIAL_PORT, self.serial_port )


Expand Down Expand Up @@ -157,8 +156,7 @@ def send_state_machine(self, sma):
sma.update_state_numbers()

message = sma.build_message()



message32 = sma.build_message_32_bits()

self._bpodcom_send_state_machine(message, message32)
Expand Down Expand Up @@ -290,6 +288,9 @@ def softcode_handler_function(self, data):
############ PRIVATE METHODS ############
#########################################

def create_session(self):
return Session()

def __process_opcode(self, sma, opcode, data, state_change_indexes):
"""
Process data from bpod board given an opcode
Expand Down
8 changes: 5 additions & 3 deletions pybpodapi/bpod/bpod_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ class BpodIO(BpodCOMProtocolModules):
def __init__(self, serial_port=None, workspace_path=None, protocol_name=None, sync_channel=None, sync_mode=None):
self.workspace_path = workspace_path if workspace_path is not None else settings.WORKSPACE_PATH
self.protocol_name = protocol_name if protocol_name is not None else settings.PROTOCOL_NAME

super(BpodIO,self).__init__(serial_port, sync_channel, sync_mode)

# type: Session
self._session = Session(os.path.join(self.workspace_path, self.protocol_name)) if self.workspace_path else Session()

self.session += SessionInfo("This is a PYBPOD file. Find more info at http://pybpod.readthedocs.io")
self.session += SessionInfo( Session.INFO_BPODAPI_VERSION, pybpodapi.__version__)
self.session += SessionInfo( Session.INFO_PROTOCOL_NAME, self.protocol_name )
self.session += SessionInfo( Session.INFO_SESSION_STARTED, self.session.start_timestamp )

super(BpodIO,self).__init__(serial_port, sync_channel, sync_mode)
def create_session(self):
return Session(os.path.join(self.workspace_path, self.protocol_name)) if self.workspace_path else Session()



def __del__(self):
Expand Down
4 changes: 2 additions & 2 deletions pybpodapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#SUPPORTED BPOD FIRMWARE VERSION
#TARGET_BPOD_FIRMWARE_VERSION = "9" # 0.7.5
#TARGET_BPOD_FIRMWARE_VERSION = "13" # 0.7.9
#TARGET_BPOD_FIRMWARE_VERSION = "15" # 0.8
TARGET_BPOD_FIRMWARE_VERSION = "17" # 0.9
TARGET_BPOD_FIRMWARE_VERSION = "15" # 0.8
#TARGET_BPOD_FIRMWARE_VERSION = "17" # 0.9

PYBPOD_API_PUBLISH_DATA_FUNC = lambda x:x

Expand Down

0 comments on commit b8850ab

Please sign in to comment.