|
@@ -1,66 +0,0 @@
|
|
|
-<template>
|
|
|
- <div>
|
|
|
- <h1>Hello WOrld</h1>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-<script type="text/javascript">
|
|
|
-export default {
|
|
|
- name: "TestContainer",
|
|
|
- data() {
|
|
|
- return {}
|
|
|
- },
|
|
|
- methods: {
|
|
|
- test() {
|
|
|
- // let CheckSum = ((0x03 + 0x00 + 0x00 + 0x00 + 0xff) ^ 0xffffffff) & 0xff;
|
|
|
- // let $CheckSum = "0x" + CheckSum.toString(16);
|
|
|
-
|
|
|
- // let buffer = new ArrayBuffer(8);
|
|
|
- // let dataView = new DataView(buffer);
|
|
|
- // dataView.setUint8(0, "0xaa");
|
|
|
- // dataView.setUint8(1, "0xcc");
|
|
|
- // dataView.setUint8(2, "0x03");
|
|
|
- // dataView.setUint8(3, "0x00");
|
|
|
- // dataView.setUint8(4, "0x00");
|
|
|
- // dataView.setUint8(5, "0x00");
|
|
|
- // dataView.setUint8(6, "0xff");
|
|
|
- // dataView.setUint8(7, $CheckSum);
|
|
|
- let $ff = "ff";
|
|
|
- let $5f = "ffffffff"
|
|
|
- let $hex_header = "aa cc ";
|
|
|
- let $hex = "03 00 01 00 0a";
|
|
|
-
|
|
|
- let $hex_sum = 0;
|
|
|
- let $hex_ary = $hex.split(" ");
|
|
|
- $hex_ary.forEach(($val, $index) => {
|
|
|
- $hex_sum += parseInt($val, 16);
|
|
|
- })
|
|
|
-
|
|
|
- let $checksum = ($hex_sum ^ parseInt($5f,16)) & parseInt($ff,16);
|
|
|
-
|
|
|
- $hex = $hex_header + $hex + " "+$checksum.toString(16);
|
|
|
- let buffer = new ArrayBuffer(8);
|
|
|
- let dataView = new DataView(buffer);
|
|
|
- $hex_ary = $hex.split(" ");
|
|
|
- $hex_ary.forEach(($val,$index)=>{
|
|
|
- dataView.setUint8($index,$val)
|
|
|
- })
|
|
|
-
|
|
|
- // dataView.setUint8(0, "0xaa");
|
|
|
- // dataView.setUint8(1, "0xcc");
|
|
|
- // dataView.setUint8(2, "0x03");
|
|
|
- // dataView.setUint8(3, "0x00");
|
|
|
- // dataView.setUint8(4, "0x00");
|
|
|
- // dataView.setUint8(5, "0x00");
|
|
|
- // dataView.setUint8(6, "0xff");
|
|
|
- // dataView.setUint8(7, $CheckSum);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- this.test();
|
|
|
- }
|
|
|
-}
|
|
|
-</script>
|