@@ -3,6 +3,7 @@ package main
33import (
44 "bytes"
55 "encoding/binary"
6+ "fmt"
67 "log"
78 "time"
89
@@ -73,6 +74,12 @@ func RunSerial(chclient chan bool, MyID uint32) {
7374 err = binary .Read (bytes .NewReader (recvbuf ), binary .BigEndian , & recvdata )
7475 CheckError (err )
7576
77+ // デバッグモード: シリアル受信データの表示
78+ if debugSerial {
79+ log .Printf ("[Serial RX] Volt: %d (%.1fV), SensorInfo: 0b%08b, CapPower: %d" ,
80+ recvdata .Volt , float32 (recvdata .Volt )* 0.1 , recvdata .SensorInformation , recvdata .CapPower )
81+ }
82+
7683 //////////////////////////////////
7784 ///
7885 /// エラーチェック部分
@@ -198,6 +205,18 @@ func RunSerial(chclient chan bool, MyID uint32) {
198205 //それぞれのデータを表示
199206 // log.Printf("VOLT: %f, BALLSENS: %t, IMUDEG: %d\n", float32(recvdata.Volt)*0.1, recvdata.IsHoldBall, recvdata.ImuDir)
200207
208+ // デバッグモード: シリアル送信データの表示
209+ if debugSerial {
210+ velx := int16 (sendbytes [1 ]) | int16 (sendbytes [2 ])<< 8
211+ vely := int16 (sendbytes [3 ]) | int16 (sendbytes [4 ])<< 8
212+ velang := int16 (sendbytes [5 ]) | int16 (sendbytes [6 ])<< 8
213+ log .Printf ("[Serial TX] VelX: %d, VelY: %d, VelAng: %d, Dribble: %d, Kick: %d, Chip: %d, Info: 0b%08b" ,
214+ velx , vely , velang , sendbytes [7 ], sendbytes [8 ], sendbytes [9 ], sendbytes [18 ])
215+ log .Printf ("[Serial TX] CamBallX: %d, CamBallY: %d, Raw: %v" ,
216+ sendbytes [16 ], sendbytes [17 ], sendbytes )
217+ fmt .Println ("---" )
218+ }
219+
201220 port .Write (sendbytes ) //書き込み
202221
203222 pre_isReceived = isReceived
0 commit comments