{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example use of binary log reader" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some includes and version check" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys \n", "sys.path.append('./binReader/')\n", "\n", "import bmmsLogReader # type: ignore\n", "import LogReaderHelpers # type: ignore\n", "\n", "if not (sys.version_info.major >= 3 and sys.version_info.minor >= 10):\n", " raise Exception(\"LogReaderHelpers requires python 3.10 or above (match case)\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the log file into memory (actually mmap)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "LogReader Size: 17150576\n", "LogReader testData/Box_15cm_4mmspacing_440nA_slopecorr3perc.taught.F00.20240129-184718.qalogTvs loaded.\n", "LogReader log file loaded! ;)\n", "Result: 0\n" ] } ], "source": [ "pcc_fName = \"testData/Box_15cm_4mmspacing_440nA_slopecorr3perc.taught.F00.20240129-184718.qalogTvs\"\n", "psBMMSLOGREADER = bmmsLogReader.BMMSLogReader()\n", "result = bmmsLogReader.bmms_bin_log_load(psBMMSLOGREADER, pcc_fName)\n", "print(f\"Result: {result}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Index the blocks and entries positions in memory" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "BlkIndex = LogReaderHelpers.bmms_bin_indexer(psBMMSLOGREADER.pcMemBlock)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Actually parse the file content" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "parsed_all = LogReaderHelpers.bmms_readData_bin_blockList(psBMMSLOGREADER.pcMemBlock,BlkIndex)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also read only specific blocks" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "bSPDV = [d for d in BlkIndex if d['id'] == LogReaderHelpers.id_to_uint32('SPDV')] #SPDD for TDS\n", "parsed_SPDV = LogReaderHelpers.bmms_readData_bin_blockList(psBMMSLOGREADER.pcMemBlock,bSPDV)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "unmap the logfile from memory and close it" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "bmmsLogReader.bmms_bin_log_unload(psBMMSLOGREADER)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "VoilĂ ... Here we have the log file content" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'Type': 'SWVE',\n", " 'Val': [('1-System-Version', 'G2_R4.3.1'),\n", " ('2-TcsFramework-Version', 'TF_R5.3.1'),\n", " ('3-Foundation-Version', 'FO_R4.2.2'),\n", " ('4-SVN-Revision', '31259')]}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "parsed_all[0]['entries'][16]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.0" } }, "nbformat": 4, "nbformat_minor": 2 }