def transferChannel(self, mode, did, channelId, apduList, apdu, timeout=2000): response = TransferChannelResponse() ret = self.dll.TransferChannel_rq(self.fd, mode, did, channelId, apduList, apdu.decode("hex"), timeout) self.__printReturn(ret, "transer channel request") self.checkReturn(ret, "transferChannel") DID = c_int(-1) c_channel_id = c_int(-1) APDUList = c_int(-1) Data = create_string_buffer(128) ReturnStatus = c_int(-1) ret = self.dll.TransferChannel_rs(self.fd, byref(DID), byref(c_channel_id), byref(APDUList), byref(Data), byref(ReturnStatus), timeout) self.__printReturn(ret, "transfer channel response") self.checkReturn(ret, "transferChannel") response.ret = ret response.did = DID.value response.channelId = c_channel_id.value response.apduList = APDUList.value response.data = Data.raw.encode("hex") response.returnStatus = ReturnStatus.value DataParser.checkChannelResponse(response) return response
def clearFileInfo(self, updateApdu): ''' updateApdu: 0700d68200020000,0700d68300020000,0600d684000100 ''' try: self.rsu.open() beaconId = "a4".decode("hex") + struct.pack( ">I", random.randint(0, 1024 * 1024 * 16))[1:] currentTime = Utils.currentTime() res = self.rsu.initialization(beaconId, currentTime, 0, 1, "418729301a00290007", 0) macId = self.rsu.getCurrentMac() self.checkCpc(macId) vstInfo = DataParser.parseCpcVstApplication(res.application) self.analyzeVstInfo(vstInfo) mac = Utils.calculateMac(self.rsu, self.cpcId, self.provider, self.stationConfig) descryption = Utils.calculateAuthDataFromMac(mac) externalAuthCmd = "0d0082000108" + descryption res = self.rsu.transferChannel(1, 1, 1, 1, externalAuthCmd) uiLog(res.data) res = self.rsu.transferChannel(1, 1, 1, 1, updateApdu) uiLog(res.data) self.rsu.eventReport() finally: self.rsu.close()
def psamChannel(self, slot, apduList, apdu, timeout=2000): res = PsamChannelResponse() ret = self.dll.PSAM_CHANNEL_rq(self.fd, slot, apduList, apdu.decode("hex"), timeout) self.__printReturn(ret, "psam channel request") self.checkReturn(ret, "psamChannel") apduNum = c_int(-1) data = create_string_buffer(256) ret = self.dll.PSAM_CHANNEL_rs(self.fd, slot, byref(apduNum), byref(data), timeout) self.__printReturn(ret, "psam channel response") self.checkReturn(ret, "psamChannel") res.ret = ret res.apduList = apduNum.value res.data = data.raw.encode("hex") DataParser.checkChannelResponse(res) return res
def broadcastTradeRun(self): vstInfo = DataParser.parseCpcVstApplication(self.vstApp) #print vstInfo.__dict__ self.analyzeVstInfo(vstInfo) self.readLocalProvinceBroadcastRoute() self.writeBroadcastRoute() self.writeTollInfo() self.rsu.eventReport()
def linkRun(self): self.getPlainVehicleInfo() routeInfo = self.readEf04RouteInfo() self.writeEf04RouteInfo() if (DataParser.checkIccStatus(self.obuStatus)): self.write08RouteInfo() self.iccCappPurchase() self.clearRouteInfo() self.rsu.setMmi(1, 1, 0) self.rsu.eventReport()
def run(self): vstInfo = DataParser.parseObuVstApplication(self.vstApp, self.obuConfiguration) self.contractSn = vstInfo.sysInfo[20:20 + 16] self.releaseId = vstInfo.sysInfo[:8] self.obuStatus = vstInfo.obuStatus self.iccSn = vstInfo.file0015[24:24 + 8 * 2] self.issuerId = vstInfo.file0015[0:8] self.iccDeliveryFactor = self.iccSn + self.issuerId + self.issuerId print "--------------------------", self.iccDeliveryFactor self.tradeMap[self.stationConfig.linkMode]()
def link11TradeRun(self): ''' link mode, aid1, channelid1 ''' vstInfo = DataParser.parseCpcVstApplication(self.vstApp) #print vstInfo.__dict__ self.analyzeVstInfo(vstInfo) self.readTollInfoLocalProvinceRouteLink11() self.writeRouteInfoChannelId1() self.writeTollInfo() self.rsu.eventReport()
def writeLinkFiles(self, routeFile, tollFile): try: self.rsu.open() beaconId = "a4".decode("hex") + struct.pack( ">I", random.randint(0, 1024 * 1024 * 16))[1:] currentTime = Utils.currentTime() res = self.rsu.initialization(beaconId, currentTime, 0, 1, "418729301a00290007", 0) macId = self.rsu.getCurrentMac() self.checkCpc(macId) vstInfo = DataParser.parseCpcVstApplication(res.application) self.analyzeVstInfo(vstInfo) mac = Utils.calculateMac(self.rsu, self.cpcId, self.provider, self.stationConfig) descryption = Utils.calculateAuthDataFromMac(mac) externalAuthCmd = "0d0082000108" + descryption res = self.rsu.transferChannel(1, 1, 1, 1, externalAuthCmd) writeRouteCmd = "0900d6820004" + routeFile writeTollCmd = "0800d6840003" + tollFile res = self.rsu.transferChannel(1, 1, 1, 2, writeRouteCmd + writeTollCmd) self.rsu.eventReport() finally: self.rsu.close()
def link10TradeRun(self): ''' link mode, aid1, channelid0 ''' vstInfo = DataParser.parseCpcVstApplication(self.vstApp) #print vstInfo.__dict__ self.analyzeVstInfo(vstInfo) if (self.isRouteFileFull == True): self.externalAuthForChannelId0FullRoute() self.readTollInfoLocalProvinceRouteLink10() else: if (self.isRouteOnePlaceLeft == True): self.writeRouteInfoChannelId0_1() self.readTollInfoLocalProvinceRouteLink10() else: if (self.isDuplicatedRoute == True): self.writeRouteInfoChannelId0_1() self.readTollInfoLocalProvinceRouteLink10() else: self.writeRouteInfoChannelId0_1() self.readTollInfoLocalProvinceRouteLink10() self.writeRouteInfoChannelId0_2() self.writeTollInfo() self.rsu.eventReport()
# ============================================ # # Data location wd = os.path.dirname(os.path.abspath(__file__)) + '/' data_path = wd + 'data/' output_path = wd + 'output/' # ============================================ # # Read data data_files = os.listdir(data_path) for i in range(len(data_files)): data_files[i] = data_path + data_files[i] dr = DataReader(data_files, col_idx) ds = DataScaler() dp = DataParser() print('======== Supplying data ============') dr.read() print('======== Extracting data ============') # ============================================ # # Split data X = dr.data[:, :target_col] y = dr.data[:, target_col] alias = list(np.unique(y)) y = dp.convertTextTarget(y, alias) #dump_result(output_path + 'accidents.csv', np.array(alias), ['accident']) print('Accident types: ', alias) # Standardize data