{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "ec5412d2", "metadata": {}, "outputs": [], "source": [ "import numpy as np \n" ] }, { "cell_type": "code", "execution_count": 2, "id": "be1f0d01", "metadata": {}, "outputs": [], "source": [ "byte1= np.array([0x12, 0xe3, 0x9b])\n", "byte2 = np.array([0x12, 0xe3, 0x9c])\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "c256a3d0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0, 0, 7], dtype=uint8)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = byte1^byte2\n", "v1 = np.array (v,dtype = np.uint8)\n", "v1" ] }, { "cell_type": "code", "execution_count": 4, "id": "227f0142", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,\n", " 1, 1], dtype=uint8)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "z = np.unpackbits(v1)\n", "z" ] }, { "cell_type": "code", "execution_count": 5, "id": "092d8dae", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = sum(z)\n", "a" ] }, { "cell_type": "markdown", "id": "1551b295", "metadata": {}, "source": [ "# TEST Längenanpassung" ] }, { "cell_type": "code", "execution_count": 6, "id": "034142b6", "metadata": {}, "outputs": [], "source": [ "test_byte=np.array([31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", "test_byte\n", "vlen= 10 " ] }, { "cell_type": "code", "execution_count": 7, "id": "f203fbce", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(test_byte)" ] }, { "cell_type": "code", "execution_count": 8, "id": "fc4fef77", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "20" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "inp= ([31, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3]+[30, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", "len(inp)" ] }, { "cell_type": "code", "execution_count": 9, "id": "74ae964c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = test_byte^inp[:vlen]\n", "v" ] }, { "cell_type": "code", "execution_count": 10, "id": "5a1d95f1", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n", "[0 0 0 0 0 0 0 0 0 0]\n" ] } ], "source": [ "for i in range(1,10):\n", " v = test_byte^inp[:vlen]\n", " print(v)" ] }, { "cell_type": "markdown", "id": "6e96c7bf", "metadata": {}, "source": [ "# Test meister Wert \n" ] }, { "cell_type": "code", "execution_count": 24, "id": "90d18368", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Length: 10\n", "Inp_vector:[31, 53, 18, 227, 155, 238, 132, 35, 65, 243]\n", "BER 6 in Paket 31\n", "BER 6 in Paket 53\n", "BER 4 in Paket 18\n", "BER 2 in Paket 227\n", "BER 4 in Paket 155\n", "BER 12 in Paket 238\n", "BER 10 in Paket 132\n", "BER 0 in Paket 35\n", "BER 6 in Paket 65\n", "BER 2 in Paket 243\n" ] } ], "source": [ "inp = ([31, 53,0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", "#inp[1] = ([31, 53,0x12, 0xe5, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", "#inp[2] = ([31, 53,0x13, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", "\n", "vgl = ([31, 53] + [0x12, 0xe3, 0x9b, 0xee, 0x84, 0x23, 0x41, 0xf3])\n", "\n", "\n", "print(f\"Length: {len(inp)}\")\n", "print(f\"Inp_vector:{inp}\")\n", " \n", "for i in inp:\n", " i = np.array(i, dtype=np.uint8)\n", " v = np.array(vgl, dtype=np.uint8) ^ i\n", " ber = sum(np.unpackbits(v))\n", "\n", " trueber = ber - 32\n", " if trueber < 0:\n", " trueber = 0\n", " print(f\"BER {trueber} in Paket {i}\")\n", "\n", " #print(f\"max BER {np.max(trueber)} in Paket {i}\")\n", " \n", " #self.send(self.encode(trueber))" ] }, { "cell_type": "code", "execution_count": null, "id": "72ca6e60", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "3a891089", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "6489bfcc", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "fda1e417", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.2" } }, "nbformat": 4, "nbformat_minor": 5 }