@@ -20,15 +20,28 @@ var debug = false
2020
2121var ws * websocket.Conn
2222var payload dw.Payload
23+ var sentSwapFile * os.File
24+ var recvSwapFile * os.File
2325
2426func init () {
2527
2628 // Print info
2729 fmt .Println ("Loaded" , program , version )
2830
2931 // Get debug flag from environment variable
30- if len (os .Getenv ("DISCON_CLIENT_DEBUG" )) > 0 {
31- debug = true
32+ csvFileName := ""
33+ csvFileName , debug = os .LookupEnv ("DISCON_CLIENT_DEBUG" )
34+ if debug {
35+ log .Println ("discon-client: DISCON_CLIENT_DEBUG=" , csvFileName )
36+ var err error
37+ sentSwapFile , err = os .Create (csvFileName + "_sent.csv" )
38+ if err != nil {
39+ log .Fatal ("discon-client: error creating sent swap file:" , err )
40+ }
41+ recvSwapFile , err = os .Create (csvFileName + "_recv.csv" )
42+ if err != nil {
43+ log .Fatal ("discon-client: error creating sent swap file:" , err )
44+ }
3245 }
3346
3447 // Get discon-server address from environment variable
@@ -119,6 +132,10 @@ func DISCON(avrSwap *C.float, aviFail *C.int, accInFile, avcOutName, avcMsg *C.c
119132
120133 if debug {
121134 log .Println ("discon-client: sent payload:\n " , payload )
135+ for _ , v := range payload .Swap [:163 ] {
136+ fmt .Fprintf (sentSwapFile , "%g," , v )
137+ }
138+ fmt .Fprintf (sentSwapFile , "%g\n " , payload .Swap [163 ])
122139 }
123140
124141 // Read response from server
@@ -135,6 +152,10 @@ func DISCON(avrSwap *C.float, aviFail *C.int, accInFile, avcOutName, avcMsg *C.c
135152
136153 if debug {
137154 log .Println ("discon-client: received payload:\n " , payload )
155+ for _ , v := range payload .Swap [:163 ] {
156+ fmt .Fprintf (recvSwapFile , "%g," , v )
157+ }
158+ fmt .Fprintf (recvSwapFile , "%g\n " , payload .Swap [163 ])
138159 }
139160
140161 // Set fail flag
0 commit comments