[{"data":1,"prerenderedAt":1687},["ShallowReactive",2],{"docs-nav-docs_cs":3,"docs-page-\u002Fcs\u002Fexamples\u002Fraw-can-python":366,"docs-surround-\u002Fcs\u002Fexamples\u002Fraw-can-python":1684},[4],{"title":5,"path":6,"stem":7,"children":8},"Cs","\u002Fcs","cs",[9,13,41,58,76,103,157,171,190,211,238,282,302],{"title":10,"path":6,"stem":11,"navTitle":12},"Dokumentace QInsight","cs\u002Findex","Přehled",{"title":14,"navTitle":15,"path":16,"stem":17,"children":18,"page":40},"Začínáme",null,"\u002Fcs\u002Fgetting-started","cs\u002F01.getting-started",[19,23,27,31,36],{"title":20,"path":21,"stem":22,"navTitle":20},"Co je QENEX Suite","\u002Fcs\u002Fgetting-started\u002Fwhat-is-qenex-suite","cs\u002F01.getting-started\u002F1.what-is-qenex-suite",{"title":24,"path":25,"stem":26,"navTitle":24},"Co je QInsight","\u002Fcs\u002Fgetting-started\u002Fwhat-is-qinsight","cs\u002F01.getting-started\u002F2.what-is-qinsight",{"title":28,"path":29,"stem":30,"navTitle":28},"Instalace","\u002Fcs\u002Fgetting-started\u002Finstallation","cs\u002F01.getting-started\u002F3.installation",{"title":32,"path":33,"stem":34,"navTitle":35},"Uživatelské rozhraní QInsight","\u002Fcs\u002Fgetting-started\u002Fthe-qinsight-interface","cs\u002F01.getting-started\u002F4.the-qinsight-interface","Uživatelské rozhraní",{"title":37,"path":38,"stem":39,"navTitle":37},"Licencování","\u002Fcs\u002Fgetting-started\u002Flicensing","cs\u002F01.getting-started\u002F5.licensing",false,{"title":42,"navTitle":15,"path":43,"stem":44,"children":45,"page":40},"První projekt","\u002Fcs\u002Ffirst-project","cs\u002F02.first-project",[46,50,54],{"title":47,"path":48,"stem":49,"navTitle":47},"Založení projektu","\u002Fcs\u002Ffirst-project\u002Fcreate-a-project","cs\u002F02.first-project\u002F1.create-a-project",{"title":51,"path":52,"stem":53,"navTitle":51},"Struktura projektu","\u002Fcs\u002Ffirst-project\u002Fproject-structure","cs\u002F02.first-project\u002F2.project-structure",{"title":55,"path":56,"stem":57,"navTitle":55},"Heslo projektu","\u002Fcs\u002Ffirst-project\u002Fproject-password","cs\u002F02.first-project\u002F3.project-password",{"title":59,"navTitle":15,"path":60,"stem":61,"children":62,"page":40},"Připojení zařízení","\u002Fcs\u002Fconnecting-a-device","cs\u002F03.connecting-a-device",[63,67,71],{"title":64,"path":65,"stem":66,"navTitle":64},"Přidání driveru","\u002Fcs\u002Fconnecting-a-device\u002Fadd-a-driver","cs\u002F03.connecting-a-device\u002F1.add-a-driver",{"title":68,"path":69,"stem":70,"navTitle":68},"Přidání protokolu","\u002Fcs\u002Fconnecting-a-device\u002Fadd-a-protocol","cs\u002F03.connecting-a-device\u002F2.add-a-protocol",{"title":72,"path":73,"stem":74,"navTitle":75},"Propojení driveru a protokolu","\u002Fcs\u002Fconnecting-a-device\u002Flink-driver-and-protocol","cs\u002F03.connecting-a-device\u002F3.link-driver-and-protocol","Propojení",{"title":77,"navTitle":15,"path":78,"stem":79,"children":80,"page":40},"Proměnné","\u002Fcs\u002Fvariables","cs\u002F04.variables",[81,85,89,93,98],{"title":82,"path":83,"stem":84,"navTitle":82},"Co je proměnná","\u002Fcs\u002Fvariables\u002Fwhat-is-a-variable","cs\u002F04.variables\u002F1.what-is-a-variable",{"title":86,"path":87,"stem":88,"navTitle":86},"Konverze a prezentace","\u002Fcs\u002Fvariables\u002Fconversion-and-presentation","cs\u002F04.variables\u002F2.conversion-and-presentation",{"title":90,"path":91,"stem":92,"navTitle":90},"Přidání proměnné","\u002Fcs\u002Fvariables\u002Fadd-a-variable","cs\u002F04.variables\u002F3.add-a-variable",{"title":94,"path":95,"stem":96,"navTitle":97},"Proměnná Matrix (pole, křivka, mapa)","\u002Fcs\u002Fvariables\u002Fmatrix-variable","cs\u002F04.variables\u002F4.matrix-variable","Proměnná Matrix",{"title":99,"path":100,"stem":101,"navTitle":102},"Události (Events)","\u002Fcs\u002Fvariables\u002Fevents","cs\u002F04.variables\u002F5.events","Události",{"title":104,"navTitle":15,"path":105,"stem":106,"children":107,"page":40},"Vizualizace","\u002Fcs\u002Fvisualization","cs\u002F05.visualization",[108,113,118,122,127,132,137,142,147,152],{"title":109,"path":110,"stem":111,"navTitle":112},"Vytvoření pracovní plochy","\u002Fcs\u002Fvisualization\u002Fcreate-a-workspace","cs\u002F05.visualization\u002F1.create-a-workspace","Pracovní plocha",{"title":114,"path":115,"stem":116,"navTitle":117},"Zápis hodnot do zařízení","\u002Fcs\u002Fvisualization\u002Fwrite-to-device","cs\u002F05.visualization\u002F10.write-to-device","Zápis do zařízení",{"title":119,"path":120,"stem":121,"navTitle":119},"Přidání controlu","\u002Fcs\u002Fvisualization\u002Fadd-a-control","cs\u002F05.visualization\u002F2.add-a-control",{"title":123,"path":124,"stem":125,"navTitle":126},"Navázání controlu na proměnnou","\u002Fcs\u002Fvisualization\u002Fbind-a-control","cs\u002F05.visualization\u002F3.bind-a-control","Navázání controlu",{"title":128,"path":129,"stem":130,"navTitle":131},"Graph — časový průběh signálů","\u002Fcs\u002Fvisualization\u002Fgraph-control","cs\u002F05.visualization\u002F4.graph-control","Graph",{"title":133,"path":134,"stem":135,"navTitle":136},"XY Graph — signál proti signálu","\u002Fcs\u002Fvisualization\u002Fxy-graph-control","cs\u002F05.visualization\u002F5.xy-graph-control","XY Graph",{"title":138,"path":139,"stem":140,"navTitle":141},"Gauge — ukazatel okamžité hodnoty","\u002Fcs\u002Fvisualization\u002Fgauge-control","cs\u002F05.visualization\u002F6.gauge-control","Gauge",{"title":143,"path":144,"stem":145,"navTitle":146},"Single-Signal — hodnota s popiskem","\u002Fcs\u002Fvisualization\u002Fsignal-control","cs\u002F05.visualization\u002F7.signal-control","Single-Signal",{"title":148,"path":149,"stem":150,"navTitle":151},"Watch Table — tabulka proměnných","\u002Fcs\u002Fvisualization\u002Fwatch-table-control","cs\u002F05.visualization\u002F8.watch-table-control","Watch Table",{"title":153,"path":154,"stem":155,"navTitle":156},"Matrix control — mapy a kalibrace","\u002Fcs\u002Fvisualization\u002Fmatrix-control","cs\u002F05.visualization\u002F9.matrix-control","Matrix control",{"title":158,"navTitle":15,"path":159,"stem":160,"children":161,"page":40},"Běh a sledování","\u002Fcs\u002Frunning","cs\u002F06.running",[162,166],{"title":163,"path":164,"stem":165,"navTitle":163},"Spuštění a zastavení","\u002Fcs\u002Frunning\u002Fstart-and-stop","cs\u002F06.running\u002F1.start-and-stop",{"title":167,"path":168,"stem":169,"navTitle":170},"Sledování živých dat","\u002Fcs\u002Frunning\u002Fwatching-live-data","cs\u002F06.running\u002F2.watching-live-data","Živá data",{"title":172,"navTitle":15,"path":173,"stem":174,"children":175,"page":40},"Logování a přehrávání","\u002Fcs\u002Flogging-and-replay","cs\u002F07.logging-and-replay",[176,180,185],{"title":177,"path":178,"stem":179,"navTitle":177},"Logování dat","\u002Fcs\u002Flogging-and-replay\u002Flogging-data","cs\u002F07.logging-and-replay\u002F1.logging-data",{"title":181,"path":182,"stem":183,"navTitle":184},"Přehrávání logu","\u002Fcs\u002Flogging-and-replay\u002Freplaying-a-log","cs\u002F07.logging-and-replay\u002F2.replaying-a-log","Přehrávání",{"title":186,"path":187,"stem":188,"navTitle":189},"Export dat","\u002Fcs\u002Flogging-and-replay\u002Fexporting-data","cs\u002F07.logging-and-replay\u002F3.exporting-data","Export",{"title":191,"navTitle":15,"path":192,"stem":193,"children":194,"page":40},"Python skripty","\u002Fcs\u002Fpython-scripts","cs\u002F08.python-scripts",[195,199,203,207],{"title":196,"path":197,"stem":198,"navTitle":12},"Přehled skriptů","\u002Fcs\u002Fpython-scripts\u002Fscripts-overview","cs\u002F08.python-scripts\u002F1.scripts-overview",{"title":200,"path":201,"stem":202,"navTitle":200},"Přístup k proměnným","\u002Fcs\u002Fpython-scripts\u002Faccessing-variables","cs\u002F08.python-scripts\u002F2.accessing-variables",{"title":204,"path":205,"stem":206,"navTitle":204},"Příklad skriptu","\u002Fcs\u002Fpython-scripts\u002Fexample-script","cs\u002F08.python-scripts\u002F3.example-script",{"title":208,"path":209,"stem":210,"navTitle":208},"Post-processing CSV","\u002Fcs\u002Fpython-scripts\u002Fcsv-post-processing","cs\u002F08.python-scripts\u002F4.csv-post-processing",{"title":212,"navTitle":15,"path":213,"stem":214,"children":215,"page":40},"Vlastní rozšíření","\u002Fcs\u002Fcustom-extensions","cs\u002F09.custom-extensions",[216,220,224,228,233],{"title":217,"path":218,"stem":219,"navTitle":217},"Vlastní driver","\u002Fcs\u002Fcustom-extensions\u002Fcustom-driver","cs\u002F09.custom-extensions\u002F1.custom-driver",{"title":221,"path":222,"stem":223,"navTitle":221},"Vlastní protokol","\u002Fcs\u002Fcustom-extensions\u002Fcustom-protocol","cs\u002F09.custom-extensions\u002F2.custom-protocol",{"title":225,"path":226,"stem":227,"navTitle":225},"Vlastní Control","\u002Fcs\u002Fcustom-extensions\u002Fcustom-control","cs\u002F09.custom-extensions\u002F3.custom-control",{"title":229,"path":230,"stem":231,"navTitle":232},"Kompletní ukázka — poloha ISS","\u002Fcs\u002Fcustom-extensions\u002Fiss-example","cs\u002F09.custom-extensions\u002F4.iss-example","Ukázka ISS",{"title":234,"path":235,"stem":236,"navTitle":237},"Kompletní ukázka — teploměr","\u002Fcs\u002Fcustom-extensions\u002Ftemp-sensor-example","cs\u002F09.custom-extensions\u002F5.temp-sensor-example","Ukázka teploměr",{"title":239,"navTitle":15,"path":240,"stem":241,"children":242,"page":40},"QFW SDK","\u002Fcs\u002Fdevice-sdk","cs\u002F10.device-sdk",[243,248,253,258,263,268,272,277],{"title":244,"path":245,"stem":246,"navTitle":247},"QFW SDK — úvod","\u002Fcs\u002Fdevice-sdk\u002Fintroduction","cs\u002F10.device-sdk\u002F1.introduction","Úvod",{"title":249,"path":250,"stem":251,"navTitle":252},"XCP v QFW SDK","\u002Fcs\u002Fdevice-sdk\u002Fxcp","cs\u002F10.device-sdk\u002F2.xcp","XCP",{"title":254,"path":255,"stem":256,"navTitle":257},"Integrace krok za krokem: XCP on TCP s FreeRTOS + lwIP","\u002Fcs\u002Fdevice-sdk\u002Fintegration-tcp","cs\u002F10.device-sdk\u002F3.integration-tcp","Integrace: XCP on TCP",{"title":259,"path":260,"stem":261,"navTitle":262},"XCP on classic CAN — co se mění","\u002Fcs\u002Fdevice-sdk\u002Fcan","cs\u002F10.device-sdk\u002F4.can","XCP on classic CAN",{"title":264,"path":265,"stem":266,"navTitle":267},"Integrace bez RTOS: XCP on TCP z hlavní smyčky","\u002Fcs\u002Fdevice-sdk\u002Fbaremetal","cs\u002F10.device-sdk\u002F5.baremetal","Integrace bez RTOS",{"title":269,"path":270,"stem":271,"navTitle":269},"Kontrakt enginu","\u002Fcs\u002Fdevice-sdk\u002Fengine-contract","cs\u002F10.device-sdk\u002F6.engine-contract",{"title":273,"path":274,"stem":275,"navTitle":276},"Adresy proměnných pro QInsight","\u002Fcs\u002Fdevice-sdk\u002Fvariable-addresses","cs\u002F10.device-sdk\u002F7.variable-addresses","Adresy proměnných",{"title":278,"path":279,"stem":280,"navTitle":281},"Řešení potíží při integraci SDK","\u002Fcs\u002Fdevice-sdk\u002Ftroubleshooting","cs\u002F10.device-sdk\u002F8.troubleshooting","Řešení potíží",{"title":283,"navTitle":15,"path":284,"stem":285,"children":286,"page":40},"Reference","\u002Fcs\u002Freference","cs\u002F11.reference",[287,291,295,299],{"title":288,"path":289,"stem":290,"navTitle":288},"Drivery","\u002Fcs\u002Freference\u002Fdrivers","cs\u002F11.reference\u002F1.drivers",{"title":292,"path":293,"stem":294,"navTitle":292},"Protokoly","\u002Fcs\u002Freference\u002Fprotocols","cs\u002F11.reference\u002F2.protocols",{"title":296,"path":297,"stem":298,"navTitle":296},"Controls","\u002Fcs\u002Freference\u002Fcontrols","cs\u002F11.reference\u002F3.controls",{"title":281,"path":300,"stem":301,"navTitle":281},"\u002Fcs\u002Freference\u002Ftroubleshooting","cs\u002F11.reference\u002F4.troubleshooting",{"title":303,"navTitle":15,"path":304,"stem":305,"children":306,"page":40},"Příklady","\u002Fcs\u002Fexamples","cs\u002F12.examples",[307,311,316,321,326,330,334,338,342,346,351,356,361],{"title":308,"path":309,"stem":310,"navTitle":308},"Simulace: všechny signály","\u002Fcs\u002Fexamples\u002Fsimulation-all-signals","cs\u002F12.examples\u002F01.simulation-all-signals",{"title":312,"path":313,"stem":314,"navTitle":315},"Modbus RTU master po sériové lince","\u002Fcs\u002Fexamples\u002Fserial-modbus-master","cs\u002F12.examples\u002F02.serial-modbus-master","Modbus RTU master",{"title":317,"path":318,"stem":319,"navTitle":320},"Modbus RTU slave se simulovanými senzory","\u002Fcs\u002Fexamples\u002Fserial-modbus-slave","cs\u002F12.examples\u002F03.serial-modbus-slave","Modbus RTU slave",{"title":322,"path":323,"stem":324,"navTitle":325},"Modbus TCP master přes TCP klienta","\u002Fcs\u002Fexamples\u002Ftcp-client-modbus-master","cs\u002F12.examples\u002F04.tcp-client-modbus-master","Modbus TCP master",{"title":327,"path":328,"stem":329,"navTitle":327},"Modbus TCP slave na TCP serveru","\u002Fcs\u002Fexamples\u002Ftcp-server-modbus-slave","cs\u002F12.examples\u002F05.tcp-server-modbus-slave",{"title":331,"path":332,"stem":333,"navTitle":331},"Bitové pole a skript","\u002Fcs\u002Fexamples\u002Fbit-field-script","cs\u002F12.examples\u002F08.bit-field-script",{"title":335,"path":336,"stem":337,"navTitle":335},"Dvě ECU najednou","\u002Fcs\u002Fexamples\u002Ftwo-ecus","cs\u002F12.examples\u002F09.two-ecus",{"title":339,"path":340,"stem":341,"navTitle":339},"Poloha ISS naživo","\u002Fcs\u002Fexamples\u002Fiss-live-tracking","cs\u002F12.examples\u002F10.iss-live-tracking",{"title":343,"path":344,"stem":345,"navTitle":343},"Simulovaný teploměr","\u002Fcs\u002Fexamples\u002Fsimul-temp-measure","cs\u002F12.examples\u002F11.simul-temp-measure",{"title":347,"path":348,"stem":349,"navTitle":350},"JSON signály z Python generátoru","\u002Fcs\u002Fexamples\u002Fjson-signal-python","cs\u002F12.examples\u002F12.json-signal-python","JSON signály z Pythonu",{"title":352,"path":353,"stem":354,"navTitle":355},"Raw CAN rámce z Raspberry","\u002Fcs\u002Fexamples\u002Fraw-can-python","cs\u002F12.examples\u002F13.raw-can-python","Raw CAN z Raspberry",{"title":357,"path":358,"stem":359,"navTitle":360},"XCP on TCP na NUCLEO-H723ZG: měření, stimulace a kalibrační mapy","\u002Fcs\u002Fexamples\u002Ftcp-client-xcp-nucleo-maps","cs\u002F12.examples\u002F14.tcp-client-xcp-nucleo-maps","XCP on TCP na NUCLEO-H723ZG",{"title":362,"path":363,"stem":364,"navTitle":365},"XCP on CAN na NUCLEO-H723ZG: měření, stimulace a kalibrační mapy","\u002Fcs\u002Fexamples\u002Fcan-xcp-nucleo-maps","cs\u002F12.examples\u002F15.can-xcp-nucleo-maps","XCP on CAN na NUCLEO-H723ZG",{"id":367,"title":352,"body":368,"description":1679,"extension":1680,"meta":1681,"navTitle":355,"navigation":916,"path":353,"seo":1682,"stem":354,"__hash__":1683},"docs_cs\u002Fcs\u002F12.examples\u002F13.raw-can-python.md",{"type":369,"value":370,"toc":1666},"minimark",[371,375,380,390,411,459,466,476,485,499,503,567,571,582,588,599,605,620,652,656,661,718,721,724,831,834,837,841,876,880,890,1641,1645,1662],[372,373,352],"h1",{"id":374},"raw-can-rámce-z-raspberry",[376,377,379],"h2",{"id":378},"princip-ukázky","Princip ukázky",[381,382,383,384,389],"p",{},"Ukázka předvádí protokol ",[385,386,388],"a",{"href":387},"\u002Fcs\u002Freference\u002Fprotocols#raw-can-frames","Raw CAN Frames",":\nhodnoty v pevných bajtech CAN rámce bez jakékoli vyšší vrstvy, tak jak je\nposílá jednoduchá elektronika nebo jak vypadají při monitorování sběrnice.",[381,391,392,393,397,398,401,402,405,406,410],{},"Protistranou je Python skript ",[394,395,396],"code",{},"Qenex_RawCan_RandomWalkGenerator.py"," ze\nsložky ",[394,399,400],{},"Examples"," vedle ",[394,403,404],{},"QInsight.exe",". Běží na Linuxu se SocketCAN,\ntypicky na ",[407,408,409],"strong",{},"Raspberry Pi s rozšiřující deskou CAN (CAN HAT)",", a:",[412,413,414,436],"ul",{},[415,416,417,420,421,424,425,428,429,424,432,435],"li",{},[407,418,419],{},"vysílá pět náhodných procházek"," ",[394,422,423],{},"rnd1"," až ",[394,426,427],{},"rnd5"," na identifikátorech\n",[394,430,431],{},"0x100",[394,433,434],{},"0x104",", 50 sad za sekundu; každý rámec má 8 bajtů: float32\nhodnota v bajtech 0–3 a float32 čas generátoru v bajtech 4–7,",[415,437,438,420,441,424,444,447,448,424,451,454,455,458],{},[407,439,440],{},"přijímá rámce",[394,442,443],{},"0x180",[394,445,446],{},"0x184"," (nový offset procházky 1 až 5)\na ",[394,449,450],{},"0x190",[394,452,453],{},"0x194"," (nový krok), float32 v bajtech 0–3. Přesně takový\nrámec QInsight pošle při zápisu do proměnné se směrem ",[394,456,457],{},"write",".",[381,460,461,462,465],{},"QInsight je na sběrnici přes adaptér ",[407,463,464],{},"PEAK PCAN-USB",", 250 kbit\u002Fs.",[467,468,473],"pre",{"className":469,"code":471,"language":472},[470],"language-text","Raspberry + CAN deska ─ 0x100: [float value][float t] ──►  PCAN-USB  ──►  QInsight (graf, watch table)\n                     ◄── 0x180: [float offset]        ──                   zápis z watch table\n","text",[394,474,471],{"__ignoreMap":475},"",[381,477,478,479,482,483,458],{},"Projekt ",[394,480,481],{},"Qenex_CAN_RawCAN_PythonRandomWalks.qproj"," je ve složce ",[394,484,400],{},[381,486,487,494],{},[488,489],"img",{"alt":490,"src":491,"className":492},"Ukázka za běhu: pět náhodných procházek z CAN sběrnice, watch table se zapisovatelnými parametry","\u002Fimg\u002FQInsight_ex_rawcan_light.png",[493],"img-light",[488,495],{"alt":490,"src":496,"className":497},"\u002Fimg\u002FQInsight_ex_rawcan_dark.png",[498],"img-dark",[376,500,502],{"id":501},"co-ukázka-předvádí","Co ukázka předvádí",[412,504,505,511,532,561],{},[415,506,507,510],{},[407,508,509],{},"Čtení"," pěti procházek ze sběrnice v grafu a v signal controlech.",[415,512,513,516,517,520,521,523,524,527,528,531],{},[407,514,515],{},"Dvě proměnné z jednoho rámce",": ",[394,518,519],{},"Rnd1"," čte bajty 0–3 rámce ",[394,522,431],{},",\n",[394,525,526],{},"Rnd1Time"," bajty 4–7 téhož rámce (",[394,529,530],{},"offset=\"4\"",").",[415,533,534,537,538,541,542,544,545,541,548,551,552,541,555,557,558,560],{},[407,535,536],{},"Zápis"," na sběrnici: ",[394,539,540],{},"Rnd1Offset"," (",[394,543,443],{},"), ",[394,546,547],{},"Rnd2Offset",[394,549,550],{},"0x181",")\na ",[394,553,554],{},"Rnd1Step",[394,556,450],{},") mají směr ",[394,559,457],{},"; zápis z watch table odešle\nrámec a procházka se přesune na nový offset.",[415,562,563,566],{},[407,564,565],{},"Časové značky z adaptéru",": vzorky nesou čas příjmu z PCAN-USB, ne\nokamžik zpracování na PC.",[376,568,570],{"id":569},"co-potřebujete","Co potřebujete",[381,572,573,574,577,578,581],{},"Na straně generátoru postačí i velmi levný hardware. Fotografie ukazuje\nsestavu, na které byla ukázka ověřena: ",[407,575,576],{},"Raspberry Pi Zero"," a modul s řadičem\n",[407,579,580],{},"MCP2515"," a budičem sběrnice TJA1050, propojený s Raspberry přes rozhraní\nSPI několika vodiči. Modul stojí řádově desítky korun a v Linuxu se chová\njako běžné rozhraní SocketCAN.",[381,583,584],{},[488,585],{"alt":586,"src":587},"Raspberry Pi Zero s modulem MCP2515 připojeným přes SPI","\u002Fimg\u002FQInsight_ex_rawcan_pizero_mcp2515.jpg",[381,589,590,591,594,595,598],{},"Modul MCP2515 se v Raspberry Pi OS aktivuje v souboru ",[394,592,593],{},"\u002Fboot\u002Ffirmware\u002Fconfig.txt","\n(u starších systémů ",[394,596,597],{},"\u002Fboot\u002Fconfig.txt","):",[467,600,603],{"className":601,"code":602,"language":472},[470],"dtparam=spi=on\ndtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25\n",[394,604,602],{"__ignoreMap":475},[381,606,607,608,611,612,615,616,619],{},"Hodnota ",[394,609,610],{},"oscillator"," odpovídá krystalu na modulu (nejčastěji 8 MHz, u některých\nmodulů 16 MHz), ",[394,613,614],{},"interrupt"," číslu GPIO, na který je připojen výstup INT modulu.\nPo restartu je k dispozici rozhraní ",[394,617,618],{},"can0",". Stejně dobře poslouží jakákoli\njiná deska CAN pro Raspberry Pi nebo jiný počítač s Linuxem a rozhraním\nSocketCAN.",[412,621,622,634],{},[415,623,624,625,627,628],{},"Raspberry Pi s rozhraním SocketCAN ",[394,626,618],{}," a Python 3. Rozhraní aktivujte\ns rychlostí 250 kbit\u002Fs a spusťte generátor:",[467,629,632],{"className":630,"code":631,"language":472},[470],"sudo ip link set can0 up type can bitrate 250000\npython3 Qenex_RawCan_RandomWalkGenerator.py\n",[394,633,631],{"__ignoreMap":475},[415,635,636,637,640,641,544,645,648,649,458],{},"PEAK PCAN-USB na PC s QInsight, sběrnice zakončená 120 Ω. V nastavení\ndriveru upravte ",[394,638,639],{},"deviceId"," na id svého adaptéru (hexadecimálně, viz\n",[385,642,644],{"href":643},"\u002Fcs\u002Freference\u002Fdrivers#peak-can-adapter","PEAK CAN",[394,646,647],{},"bitrate"," zůstává\n",[394,650,651],{},"250000",[376,653,655],{"id":654},"projekt","Projekt",[657,658,660],"h3",{"id":659},"driver-a-protokol","Driver a protokol",[662,663,664,677],"table",{},[665,666,667],"thead",{},[668,669,670,674],"tr",{},[671,672,673],"th",{},"Driver PCAN-USB",[671,675,676],{},"Význam",[678,679,680,694,704],"tbody",{},[668,681,682,688],{},[683,684,685],"td",{},[394,686,687],{},"deviceId=0xff",[683,689,690,691],{},"id adaptéru z PEAK nastavení — ",[407,692,693],{},"upravte",[668,695,696,701],{},[683,697,698],{},[394,699,700],{},"bitrate=250000",[683,702,703],{},"rychlost sběrnice, stejná jako na Raspberry",[668,705,706,715],{},[683,707,708,711,712],{},[394,709,710],{},"reconnectDelayMs=1000",", ",[394,713,714],{},"reconnectAttempts=-1",[683,716,717],{},"po odpojení adaptéru se pokouší o obnovení bez omezení počtu pokusů",[381,719,720],{},"Protokol nemá nastavení.",[657,722,77],{"id":723},"proměnné",[662,725,726,741],{},[665,727,728],{},[668,729,730,733,736,739],{},[671,731,732],{},"Proměnná",[671,734,735],{},"Typ",[671,737,738],{},"Comm params",[671,740,676],{},[678,742,743,764,780,797,814],{},[668,744,745,753,756,761],{},[683,746,747,749,750],{},[394,748,519],{}," … ",[394,751,752],{},"Rnd5",[683,754,755],{},"float",[683,757,758],{},[394,759,760],{},"direction=\"read\";canId=\"0x100\"…\"0x104\";offset=\"0\";byteOrder=\"le\"",[683,762,763],{},"procházky",[668,765,766,770,772,777],{},[683,767,768],{},[394,769,526],{},[683,771,755],{},[683,773,774],{},[394,775,776],{},"direction=\"read\";canId=\"0x100\";offset=\"4\"",[683,778,779],{},"čas generátoru z druhé poloviny rámce",[668,781,782,787,789,794],{},[683,783,784],{},[394,785,786],{},"Params\u002FRnd1Offset",[683,788,755],{},[683,790,791],{},[394,792,793],{},"direction=\"write\";canId=\"0x180\"",[683,795,796],{},"nový offset procházky 1",[668,798,799,804,806,811],{},[683,800,801],{},[394,802,803],{},"Params\u002FRnd2Offset",[683,805,755],{},[683,807,808],{},[394,809,810],{},"direction=\"write\";canId=\"0x181\"",[683,812,813],{},"nový offset procházky 2",[668,815,816,821,823,828],{},[683,817,818],{},[394,819,820],{},"Params\u002FRnd1Step",[683,822,755],{},[683,824,825],{},[394,826,827],{},"direction=\"write\";canId=\"0x190\"",[683,829,830],{},"krok procházky 1",[657,832,112],{"id":833},"pracovní-plocha",[381,835,836],{},"Graf všech pěti procházek, watch table se třemi zapisovatelnými\nparametry, signal control času generátoru a pět signal controlů hodnot.",[376,838,840],{"id":839},"co-uvidíte-a-co-vyzkoušet","Co uvidíte a co vyzkoušet",[412,842,843,853,866,869],{},[415,844,845,846,849,850,852],{},"Po ",[407,847,848],{},"Startu"," se rozběhne pět procházek kolem svých offsetů 0, 10, −5,\n20 a 5. ",[394,851,526],{}," roste od spuštění generátoru.",[415,854,855,856,858,859,862,863,865],{},"Zapište ",[394,857,540],{}," = 15: procházka 1 se přesune na hodnotu 15 a dále\nkolísá kolem ní; generátor vypíše ",[394,860,861],{},"rnd1.O = 15.000",". ",[394,864,554],{}," = 5\nzvětší její krok, 0.1 ho zmenší.",[415,867,868],{},"Odpojte adaptér PCAN-USB: driver ohlásí ztrátu adaptéru a pokouší se ho\notevřít každou sekundu; po opětovném připojení příjem pokračuje a časové\nznačky se znovu synchronizují.",[415,870,871,872,875],{},"Do Comm params proměnné zapište ",[394,873,874],{},"canId=\"zz\""," a potvrďte tlačítkem Apply:\nproměnná se v logu ohlásí jako nekomunikovaná s uvedením důvodu, místo\naby zůstala bez hlášení.",[376,877,879],{"id":878},"skript-generátoru","Skript generátoru",[381,881,882,883,885,886,889],{},"Celý ",[394,884,396],{},"; rozložení rámců je\nv docstringu. Pro vlastní zařízení stačí převzít stavbu rámce\n(",[394,887,888],{},"struct.pack(\"\u003Cff\", value, t)",") a čtení řídicích rámců.",[467,891,895],{"className":892,"code":893,"language":894,"meta":475,"style":475},"language-python shiki shiki-themes github-light github-dark-default","#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Random-walk CAN generator - the counterpart of QInsight's Raw CAN Frames protocol.\n\nRuns on a Linux machine with a SocketCAN interface, typically a Raspberry Pi with a CAN HAT\n(QInsight sits on the other end of the bus with a PEAK PCAN-USB adapter):\n\n    sudo ip link set can0 up type can bitrate 250000\n    python3 Qenex_RawCan_RandomWalkGenerator.py              # can0, 50 sets of frames per second\n    python3 Qenex_RawCan_RandomWalkGenerator.py --channel can1 --hz 20\n\nShipped with QInsight in the Examples folder; used by the example\nQenex_CAN_RawCAN_PythonRandomWalks.qproj.\n\nFrames sent (standard 11-bit ids, DLC 8, little-endian):\n    id 0x100 .. 0x104   rnd1 .. rnd5   bytes 0-3 float32 value, bytes 4-7 float32 time t [s]\nEach signal is a random walk: every sample moves by a random step in +-step and a weak\nmean reversion pulls it back towards its offset O, so it never drifts off the chart.\n\nFrames accepted (what QInsight sends for a Raw CAN variable with direction=\"write\"):\n    id 0x180 .. 0x184   bytes 0-3 float32   new offset O of rnd1 .. rnd5\n    id 0x190 .. 0x194   bytes 0-3 float32   new step size of rnd1 .. rnd5\nThe walk jumps to the new offset at once, so a write is visible immediately on the graph.\n\"\"\"\nimport argparse\nimport random\nimport socket\nimport struct\nimport threading\nimport time\n\n# id -> random-walk parameters\n#   O          = offset (the value the walk hovers around)\n#   step       = max size of one random step; each sample moves by +-step\n#   reversion  = mean-reversion strength (0..1); pulls the value back towards O\nSIGNALS = {\n    0x100: {\"O\":  0.0, \"step\": 0.5, \"reversion\": 0.01},\n    0x101: {\"O\": 10.0, \"step\": 1.0, \"reversion\": 0.02},\n    0x102: {\"O\": -5.0, \"step\": 0.3, \"reversion\": 0.015},\n    0x103: {\"O\": 20.0, \"step\": 2.0, \"reversion\": 0.01},\n    0x104: {\"O\":  5.0, \"step\": 0.8, \"reversion\": 0.03},\n}\nOFFSET_ID_BASE = 0x180   # 0x180 + n sets O of the n-th signal\nSTEP_ID_BASE = 0x190     # 0x190 + n sets step of the n-th signal\n\nFRAME_FORMAT = \"=IB3x8s\"  # SocketCAN frame: id (4), dlc (1), padding (3), data (8)\nCAN_EFF_FLAG = 0x80000000\n\nlock = threading.Lock()\nSTATE = {cid: p[\"O\"] for cid, p in SIGNALS.items()}   # current value of every walk\n\n\ndef step_walk(can_id):\n    \"\"\"Advance one random walk by one step and return the new value.\"\"\"\n    with lock:\n        p = SIGNALS[can_id]\n        x = STATE[can_id]\n        x = x + random.uniform(-p[\"step\"], p[\"step\"]) + p[\"reversion\"] * (p[\"O\"] - x)\n        STATE[can_id] = x\n        return x\n\n\ndef build_frame(can_id, value, t):\n    data = struct.pack(\"\u003Cff\", value, t)        # 8 B: float32 value + float32 t\n    return struct.pack(FRAME_FORMAT, can_id, len(data), data)\n\n\ndef apply_frame(raw):\n    \"\"\"A received frame: 0x18n \u002F 0x19n with a float32 sets offset \u002F step of signal n.\"\"\"\n    can_id, dlc, data = struct.unpack(FRAME_FORMAT, raw)\n    if can_id & CAN_EFF_FLAG or dlc \u003C 4:\n        return\n    can_id &= 0x7FF\n    for base, key in ((OFFSET_ID_BASE, \"O\"), (STEP_ID_BASE, \"step\")):\n        n = can_id - base\n        if 0 \u003C= n \u003C len(SIGNALS):\n            signal_id = 0x100 + n\n            value = struct.unpack(\"\u003Cf\", data[:4])[0]\n            with lock:\n                SIGNALS[signal_id][key] = value\n                if key == \"O\":\n                    STATE[signal_id] = value      # jump there, so the write shows at once\n            print(f\"rnd{n + 1}.{key} = {value:.3f}\", flush=True)\n            return\n\n\ndef reader_thread(sock, stop):\n    while not stop.is_set():\n        try:\n            raw = sock.recv(16)\n        except OSError:\n            break\n        if len(raw) == 16:\n            apply_frame(raw)\n\n\ndef main():\n    parser = argparse.ArgumentParser(description=\"Raw CAN random-walk generator for QInsight (SocketCAN).\")\n    parser.add_argument(\"--channel\", default=\"can0\", help=\"SocketCAN interface (default can0)\")\n    parser.add_argument(\"--hz\", type=float, default=50.0, help=\"sets of 5 frames per second (default 50)\")\n    args = parser.parse_args()\n\n    sock = socket.socket(socket.AF_CAN, socket.SOCK_RAW, socket.CAN_RAW)\n    sock.bind((args.channel,))\n    stop = threading.Event()\n    threading.Thread(target=reader_thread, args=(sock, stop), daemon=True).start()\n\n    t0 = time.monotonic()\n    period = 1.0 \u002F args.hz\n    next_t = time.monotonic()\n    print(f\"Raw CAN generator on {args.channel}: ids 0x100-0x104 @ {args.hz:g} Hz, \"\n          f\"writes on 0x180-0x184 (offset) and 0x190-0x194 (step). Ctrl+C to stop.\", flush=True)\n    try:\n        while True:\n            t = time.monotonic() - t0\n            for can_id in SIGNALS:                 # 5 frames, one signal each\n                sock.send(build_frame(can_id, step_walk(can_id), t))\n            next_t += period\n            time.sleep(max(0.0, next_t - time.monotonic()))\n    except KeyboardInterrupt:\n        pass\n    finally:\n        stop.set()\n        sock.close()\n\n\nif __name__ == \"__main__\":\n    main()\n","python",[394,896,897,905,911,918,924,930,935,941,947,953,958,964,970,975,981,987,993,999,1004,1010,1016,1022,1028,1034,1040,1046,1052,1058,1064,1070,1075,1081,1087,1093,1099,1105,1111,1117,1123,1129,1135,1141,1147,1153,1158,1164,1170,1175,1181,1187,1192,1197,1203,1209,1215,1221,1227,1233,1239,1245,1250,1255,1261,1267,1273,1278,1283,1289,1295,1301,1307,1313,1319,1325,1331,1337,1343,1349,1355,1361,1367,1373,1379,1385,1390,1395,1401,1407,1413,1419,1425,1431,1437,1443,1448,1453,1459,1465,1471,1477,1483,1488,1494,1500,1506,1512,1517,1523,1529,1535,1541,1547,1553,1559,1565,1571,1577,1583,1589,1595,1601,1607,1613,1619,1624,1629,1635],{"__ignoreMap":475},[898,899,902],"span",{"class":900,"line":901},"line",1,[898,903,904],{},"#!\u002Fusr\u002Fbin\u002Fenv python3\n",[898,906,908],{"class":900,"line":907},2,[898,909,910],{},"\"\"\"Random-walk CAN generator - the counterpart of QInsight's Raw CAN Frames protocol.\n",[898,912,914],{"class":900,"line":913},3,[898,915,917],{"emptyLinePlaceholder":916},true,"\n",[898,919,921],{"class":900,"line":920},4,[898,922,923],{},"Runs on a Linux machine with a SocketCAN interface, typically a Raspberry Pi with a CAN HAT\n",[898,925,927],{"class":900,"line":926},5,[898,928,929],{},"(QInsight sits on the other end of the bus with a PEAK PCAN-USB adapter):\n",[898,931,933],{"class":900,"line":932},6,[898,934,917],{"emptyLinePlaceholder":916},[898,936,938],{"class":900,"line":937},7,[898,939,940],{},"    sudo ip link set can0 up type can bitrate 250000\n",[898,942,944],{"class":900,"line":943},8,[898,945,946],{},"    python3 Qenex_RawCan_RandomWalkGenerator.py              # can0, 50 sets of frames per second\n",[898,948,950],{"class":900,"line":949},9,[898,951,952],{},"    python3 Qenex_RawCan_RandomWalkGenerator.py --channel can1 --hz 20\n",[898,954,956],{"class":900,"line":955},10,[898,957,917],{"emptyLinePlaceholder":916},[898,959,961],{"class":900,"line":960},11,[898,962,963],{},"Shipped with QInsight in the Examples folder; used by the example\n",[898,965,967],{"class":900,"line":966},12,[898,968,969],{},"Qenex_CAN_RawCAN_PythonRandomWalks.qproj.\n",[898,971,973],{"class":900,"line":972},13,[898,974,917],{"emptyLinePlaceholder":916},[898,976,978],{"class":900,"line":977},14,[898,979,980],{},"Frames sent (standard 11-bit ids, DLC 8, little-endian):\n",[898,982,984],{"class":900,"line":983},15,[898,985,986],{},"    id 0x100 .. 0x104   rnd1 .. rnd5   bytes 0-3 float32 value, bytes 4-7 float32 time t [s]\n",[898,988,990],{"class":900,"line":989},16,[898,991,992],{},"Each signal is a random walk: every sample moves by a random step in +-step and a weak\n",[898,994,996],{"class":900,"line":995},17,[898,997,998],{},"mean reversion pulls it back towards its offset O, so it never drifts off the chart.\n",[898,1000,1002],{"class":900,"line":1001},18,[898,1003,917],{"emptyLinePlaceholder":916},[898,1005,1007],{"class":900,"line":1006},19,[898,1008,1009],{},"Frames accepted (what QInsight sends for a Raw CAN variable with direction=\"write\"):\n",[898,1011,1013],{"class":900,"line":1012},20,[898,1014,1015],{},"    id 0x180 .. 0x184   bytes 0-3 float32   new offset O of rnd1 .. rnd5\n",[898,1017,1019],{"class":900,"line":1018},21,[898,1020,1021],{},"    id 0x190 .. 0x194   bytes 0-3 float32   new step size of rnd1 .. rnd5\n",[898,1023,1025],{"class":900,"line":1024},22,[898,1026,1027],{},"The walk jumps to the new offset at once, so a write is visible immediately on the graph.\n",[898,1029,1031],{"class":900,"line":1030},23,[898,1032,1033],{},"\"\"\"\n",[898,1035,1037],{"class":900,"line":1036},24,[898,1038,1039],{},"import argparse\n",[898,1041,1043],{"class":900,"line":1042},25,[898,1044,1045],{},"import random\n",[898,1047,1049],{"class":900,"line":1048},26,[898,1050,1051],{},"import socket\n",[898,1053,1055],{"class":900,"line":1054},27,[898,1056,1057],{},"import struct\n",[898,1059,1061],{"class":900,"line":1060},28,[898,1062,1063],{},"import threading\n",[898,1065,1067],{"class":900,"line":1066},29,[898,1068,1069],{},"import time\n",[898,1071,1073],{"class":900,"line":1072},30,[898,1074,917],{"emptyLinePlaceholder":916},[898,1076,1078],{"class":900,"line":1077},31,[898,1079,1080],{},"# id -> random-walk parameters\n",[898,1082,1084],{"class":900,"line":1083},32,[898,1085,1086],{},"#   O          = offset (the value the walk hovers around)\n",[898,1088,1090],{"class":900,"line":1089},33,[898,1091,1092],{},"#   step       = max size of one random step; each sample moves by +-step\n",[898,1094,1096],{"class":900,"line":1095},34,[898,1097,1098],{},"#   reversion  = mean-reversion strength (0..1); pulls the value back towards O\n",[898,1100,1102],{"class":900,"line":1101},35,[898,1103,1104],{},"SIGNALS = {\n",[898,1106,1108],{"class":900,"line":1107},36,[898,1109,1110],{},"    0x100: {\"O\":  0.0, \"step\": 0.5, \"reversion\": 0.01},\n",[898,1112,1114],{"class":900,"line":1113},37,[898,1115,1116],{},"    0x101: {\"O\": 10.0, \"step\": 1.0, \"reversion\": 0.02},\n",[898,1118,1120],{"class":900,"line":1119},38,[898,1121,1122],{},"    0x102: {\"O\": -5.0, \"step\": 0.3, \"reversion\": 0.015},\n",[898,1124,1126],{"class":900,"line":1125},39,[898,1127,1128],{},"    0x103: {\"O\": 20.0, \"step\": 2.0, \"reversion\": 0.01},\n",[898,1130,1132],{"class":900,"line":1131},40,[898,1133,1134],{},"    0x104: {\"O\":  5.0, \"step\": 0.8, \"reversion\": 0.03},\n",[898,1136,1138],{"class":900,"line":1137},41,[898,1139,1140],{},"}\n",[898,1142,1144],{"class":900,"line":1143},42,[898,1145,1146],{},"OFFSET_ID_BASE = 0x180   # 0x180 + n sets O of the n-th signal\n",[898,1148,1150],{"class":900,"line":1149},43,[898,1151,1152],{},"STEP_ID_BASE = 0x190     # 0x190 + n sets step of the n-th signal\n",[898,1154,1156],{"class":900,"line":1155},44,[898,1157,917],{"emptyLinePlaceholder":916},[898,1159,1161],{"class":900,"line":1160},45,[898,1162,1163],{},"FRAME_FORMAT = \"=IB3x8s\"  # SocketCAN frame: id (4), dlc (1), padding (3), data (8)\n",[898,1165,1167],{"class":900,"line":1166},46,[898,1168,1169],{},"CAN_EFF_FLAG = 0x80000000\n",[898,1171,1173],{"class":900,"line":1172},47,[898,1174,917],{"emptyLinePlaceholder":916},[898,1176,1178],{"class":900,"line":1177},48,[898,1179,1180],{},"lock = threading.Lock()\n",[898,1182,1184],{"class":900,"line":1183},49,[898,1185,1186],{},"STATE = {cid: p[\"O\"] for cid, p in SIGNALS.items()}   # current value of every walk\n",[898,1188,1190],{"class":900,"line":1189},50,[898,1191,917],{"emptyLinePlaceholder":916},[898,1193,1195],{"class":900,"line":1194},51,[898,1196,917],{"emptyLinePlaceholder":916},[898,1198,1200],{"class":900,"line":1199},52,[898,1201,1202],{},"def step_walk(can_id):\n",[898,1204,1206],{"class":900,"line":1205},53,[898,1207,1208],{},"    \"\"\"Advance one random walk by one step and return the new value.\"\"\"\n",[898,1210,1212],{"class":900,"line":1211},54,[898,1213,1214],{},"    with lock:\n",[898,1216,1218],{"class":900,"line":1217},55,[898,1219,1220],{},"        p = SIGNALS[can_id]\n",[898,1222,1224],{"class":900,"line":1223},56,[898,1225,1226],{},"        x = STATE[can_id]\n",[898,1228,1230],{"class":900,"line":1229},57,[898,1231,1232],{},"        x = x + random.uniform(-p[\"step\"], p[\"step\"]) + p[\"reversion\"] * (p[\"O\"] - x)\n",[898,1234,1236],{"class":900,"line":1235},58,[898,1237,1238],{},"        STATE[can_id] = x\n",[898,1240,1242],{"class":900,"line":1241},59,[898,1243,1244],{},"        return x\n",[898,1246,1248],{"class":900,"line":1247},60,[898,1249,917],{"emptyLinePlaceholder":916},[898,1251,1253],{"class":900,"line":1252},61,[898,1254,917],{"emptyLinePlaceholder":916},[898,1256,1258],{"class":900,"line":1257},62,[898,1259,1260],{},"def build_frame(can_id, value, t):\n",[898,1262,1264],{"class":900,"line":1263},63,[898,1265,1266],{},"    data = struct.pack(\"\u003Cff\", value, t)        # 8 B: float32 value + float32 t\n",[898,1268,1270],{"class":900,"line":1269},64,[898,1271,1272],{},"    return struct.pack(FRAME_FORMAT, can_id, len(data), data)\n",[898,1274,1276],{"class":900,"line":1275},65,[898,1277,917],{"emptyLinePlaceholder":916},[898,1279,1281],{"class":900,"line":1280},66,[898,1282,917],{"emptyLinePlaceholder":916},[898,1284,1286],{"class":900,"line":1285},67,[898,1287,1288],{},"def apply_frame(raw):\n",[898,1290,1292],{"class":900,"line":1291},68,[898,1293,1294],{},"    \"\"\"A received frame: 0x18n \u002F 0x19n with a float32 sets offset \u002F step of signal n.\"\"\"\n",[898,1296,1298],{"class":900,"line":1297},69,[898,1299,1300],{},"    can_id, dlc, data = struct.unpack(FRAME_FORMAT, raw)\n",[898,1302,1304],{"class":900,"line":1303},70,[898,1305,1306],{},"    if can_id & CAN_EFF_FLAG or dlc \u003C 4:\n",[898,1308,1310],{"class":900,"line":1309},71,[898,1311,1312],{},"        return\n",[898,1314,1316],{"class":900,"line":1315},72,[898,1317,1318],{},"    can_id &= 0x7FF\n",[898,1320,1322],{"class":900,"line":1321},73,[898,1323,1324],{},"    for base, key in ((OFFSET_ID_BASE, \"O\"), (STEP_ID_BASE, \"step\")):\n",[898,1326,1328],{"class":900,"line":1327},74,[898,1329,1330],{},"        n = can_id - base\n",[898,1332,1334],{"class":900,"line":1333},75,[898,1335,1336],{},"        if 0 \u003C= n \u003C len(SIGNALS):\n",[898,1338,1340],{"class":900,"line":1339},76,[898,1341,1342],{},"            signal_id = 0x100 + n\n",[898,1344,1346],{"class":900,"line":1345},77,[898,1347,1348],{},"            value = struct.unpack(\"\u003Cf\", data[:4])[0]\n",[898,1350,1352],{"class":900,"line":1351},78,[898,1353,1354],{},"            with lock:\n",[898,1356,1358],{"class":900,"line":1357},79,[898,1359,1360],{},"                SIGNALS[signal_id][key] = value\n",[898,1362,1364],{"class":900,"line":1363},80,[898,1365,1366],{},"                if key == \"O\":\n",[898,1368,1370],{"class":900,"line":1369},81,[898,1371,1372],{},"                    STATE[signal_id] = value      # jump there, so the write shows at once\n",[898,1374,1376],{"class":900,"line":1375},82,[898,1377,1378],{},"            print(f\"rnd{n + 1}.{key} = {value:.3f}\", flush=True)\n",[898,1380,1382],{"class":900,"line":1381},83,[898,1383,1384],{},"            return\n",[898,1386,1388],{"class":900,"line":1387},84,[898,1389,917],{"emptyLinePlaceholder":916},[898,1391,1393],{"class":900,"line":1392},85,[898,1394,917],{"emptyLinePlaceholder":916},[898,1396,1398],{"class":900,"line":1397},86,[898,1399,1400],{},"def reader_thread(sock, stop):\n",[898,1402,1404],{"class":900,"line":1403},87,[898,1405,1406],{},"    while not stop.is_set():\n",[898,1408,1410],{"class":900,"line":1409},88,[898,1411,1412],{},"        try:\n",[898,1414,1416],{"class":900,"line":1415},89,[898,1417,1418],{},"            raw = sock.recv(16)\n",[898,1420,1422],{"class":900,"line":1421},90,[898,1423,1424],{},"        except OSError:\n",[898,1426,1428],{"class":900,"line":1427},91,[898,1429,1430],{},"            break\n",[898,1432,1434],{"class":900,"line":1433},92,[898,1435,1436],{},"        if len(raw) == 16:\n",[898,1438,1440],{"class":900,"line":1439},93,[898,1441,1442],{},"            apply_frame(raw)\n",[898,1444,1446],{"class":900,"line":1445},94,[898,1447,917],{"emptyLinePlaceholder":916},[898,1449,1451],{"class":900,"line":1450},95,[898,1452,917],{"emptyLinePlaceholder":916},[898,1454,1456],{"class":900,"line":1455},96,[898,1457,1458],{},"def main():\n",[898,1460,1462],{"class":900,"line":1461},97,[898,1463,1464],{},"    parser = argparse.ArgumentParser(description=\"Raw CAN random-walk generator for QInsight (SocketCAN).\")\n",[898,1466,1468],{"class":900,"line":1467},98,[898,1469,1470],{},"    parser.add_argument(\"--channel\", default=\"can0\", help=\"SocketCAN interface (default can0)\")\n",[898,1472,1474],{"class":900,"line":1473},99,[898,1475,1476],{},"    parser.add_argument(\"--hz\", type=float, default=50.0, help=\"sets of 5 frames per second (default 50)\")\n",[898,1478,1480],{"class":900,"line":1479},100,[898,1481,1482],{},"    args = parser.parse_args()\n",[898,1484,1486],{"class":900,"line":1485},101,[898,1487,917],{"emptyLinePlaceholder":916},[898,1489,1491],{"class":900,"line":1490},102,[898,1492,1493],{},"    sock = socket.socket(socket.AF_CAN, socket.SOCK_RAW, socket.CAN_RAW)\n",[898,1495,1497],{"class":900,"line":1496},103,[898,1498,1499],{},"    sock.bind((args.channel,))\n",[898,1501,1503],{"class":900,"line":1502},104,[898,1504,1505],{},"    stop = threading.Event()\n",[898,1507,1509],{"class":900,"line":1508},105,[898,1510,1511],{},"    threading.Thread(target=reader_thread, args=(sock, stop), daemon=True).start()\n",[898,1513,1515],{"class":900,"line":1514},106,[898,1516,917],{"emptyLinePlaceholder":916},[898,1518,1520],{"class":900,"line":1519},107,[898,1521,1522],{},"    t0 = time.monotonic()\n",[898,1524,1526],{"class":900,"line":1525},108,[898,1527,1528],{},"    period = 1.0 \u002F args.hz\n",[898,1530,1532],{"class":900,"line":1531},109,[898,1533,1534],{},"    next_t = time.monotonic()\n",[898,1536,1538],{"class":900,"line":1537},110,[898,1539,1540],{},"    print(f\"Raw CAN generator on {args.channel}: ids 0x100-0x104 @ {args.hz:g} Hz, \"\n",[898,1542,1544],{"class":900,"line":1543},111,[898,1545,1546],{},"          f\"writes on 0x180-0x184 (offset) and 0x190-0x194 (step). Ctrl+C to stop.\", flush=True)\n",[898,1548,1550],{"class":900,"line":1549},112,[898,1551,1552],{},"    try:\n",[898,1554,1556],{"class":900,"line":1555},113,[898,1557,1558],{},"        while True:\n",[898,1560,1562],{"class":900,"line":1561},114,[898,1563,1564],{},"            t = time.monotonic() - t0\n",[898,1566,1568],{"class":900,"line":1567},115,[898,1569,1570],{},"            for can_id in SIGNALS:                 # 5 frames, one signal each\n",[898,1572,1574],{"class":900,"line":1573},116,[898,1575,1576],{},"                sock.send(build_frame(can_id, step_walk(can_id), t))\n",[898,1578,1580],{"class":900,"line":1579},117,[898,1581,1582],{},"            next_t += period\n",[898,1584,1586],{"class":900,"line":1585},118,[898,1587,1588],{},"            time.sleep(max(0.0, next_t - time.monotonic()))\n",[898,1590,1592],{"class":900,"line":1591},119,[898,1593,1594],{},"    except KeyboardInterrupt:\n",[898,1596,1598],{"class":900,"line":1597},120,[898,1599,1600],{},"        pass\n",[898,1602,1604],{"class":900,"line":1603},121,[898,1605,1606],{},"    finally:\n",[898,1608,1610],{"class":900,"line":1609},122,[898,1611,1612],{},"        stop.set()\n",[898,1614,1616],{"class":900,"line":1615},123,[898,1617,1618],{},"        sock.close()\n",[898,1620,1622],{"class":900,"line":1621},124,[898,1623,917],{"emptyLinePlaceholder":916},[898,1625,1627],{"class":900,"line":1626},125,[898,1628,917],{"emptyLinePlaceholder":916},[898,1630,1632],{"class":900,"line":1631},126,[898,1633,1634],{},"if __name__ == \"__main__\":\n",[898,1636,1638],{"class":900,"line":1637},127,[898,1639,1640],{},"    main()\n",[376,1642,1644],{"id":1643},"související-kapitoly","Související kapitoly",[412,1646,1647,1652,1657],{},[415,1648,1649,1651],{},[385,1650,388],{"href":387}," v referenci protokolů",[415,1653,1654,1656],{},[385,1655,644],{"href":643}," v referenci driverů",[415,1658,1659,1661],{},[385,1660,365],{"href":363}," — tentýž adaptér s protokolem XCP",[1663,1664,1665],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":475,"searchDepth":913,"depth":913,"links":1667},[1668,1669,1670,1671,1676,1677,1678],{"id":378,"depth":907,"text":379},{"id":501,"depth":907,"text":502},{"id":569,"depth":907,"text":570},{"id":654,"depth":907,"text":655,"children":1672},[1673,1674,1675],{"id":659,"depth":913,"text":660},{"id":723,"depth":913,"text":77},{"id":833,"depth":913,"text":112},{"id":839,"depth":907,"text":840},{"id":878,"depth":907,"text":879},{"id":1643,"depth":907,"text":1644},"Ukázka protokolu Raw CAN Frames — pět náhodných procházek posílaných jako surové CAN rámce z Raspberry Pi s rozšiřující deskou CAN, čtených přes PEAK PCAN-USB, se zápisem offsetu a kroku zpět na sběrnici.","md",{},{"title":352,"description":1679},"enl89YzDN9ARnFWpBepMZgMFWdofJTlUlKncC6IPrdM",[1685,1686],{"title":347,"path":348,"stem":349,"navTitle":350,"children":-1},{"title":357,"path":358,"stem":359,"navTitle":360,"children":-1},1791554569419]