"ERROR: failed to load fw 1", Raspberry Pi 2 B+ LoRa gateway - raspberry-pi

I've been through countless forums discussing the same issue, but with no luck.
I'm trying to setup the WiMOD Lite Gateway (Raspberry Pi 2 B+ and iC880A-SPI) with the lora_gateway, but without the packet_forwarder because I intend to use the Azure IoT Edge Starterkit instead. Before installing that, I want to check the functionality of the lora_gateway, so I'm trying to get the packet logger to work.
When I run the util_pkt_logger, I get the following errors:
loragw_pkt_logger: INFO: found global configuration file global_conf.json, trying to parse it
loragw_pkt_logger: INFO: global_conf.json does contain a JSON object named SX1301_conf, parsing SX1301 parameters
loragw_pkt_logger: INFO: lorawan_public 1, clksrc 1
loragw_pkt_logger: INFO: radio 0 enabled (type SX1257), center frequency 867500000, RSSI offset -166.000000, tx enabled 0, tx_notch_freq 0
loragw_pkt_logger: INFO: radio 1 enabled (type SX1257), center frequency 868500000, RSSI offset -166.000000, tx enabled 0, tx_notch_freq 0
loragw_pkt_logger: INFO: LoRa multi-SF channel 0 enabled, radio 1 selected, IF -400000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 1 enabled, radio 1 selected, IF -200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 2 enabled, radio 1 selected, IF 0 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 3 enabled, radio 0 selected, IF -400000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 4 enabled, radio 0 selected, IF -200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 5 enabled, radio 0 selected, IF 0 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 6 enabled, radio 0 selected, IF 200000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa multi-SF channel 7 enabled, radio 0 selected, IF 400000 Hz, 125 kHz bandwidth, SF 7 to 12
loragw_pkt_logger: INFO: LoRa standard channel enabled, radio 1 selected, IF -200000 Hz, 250000 Hz bandwidth, SF 7
loragw_pkt_logger: INFO: FSK channel enabled, radio 1 selected, IF 300000 Hz, 125000 Hz bandwidth, 50000 bps datarate
loragw_pkt_logger: INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
loragw_pkt_logger: INFO: gateway MAC address is configured to AA555A0000000000
loragw_pkt_logger: INFO: found local configuration file local_conf.json, trying to parse it
loragw_pkt_logger: INFO: local_conf.json does not contain a JSON object named SX1301_conf
loragw_pkt_logger: INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
loragw_pkt_logger: INFO: gateway MAC address is configured to AA555A0000000101
ERROR: Failed to load fw 1
ERROR: Version of calibration firmware not expected, actual:0 expected:2
loragw_pkt_logger: ERROR: failed to start the concentrator
When I run the util_spi_stress, I get the following:
INFO: Starting LoRa concentrator SPI stress-test number 1
Cycle 0 > error during the 1th iteration: write 0x67, read 0x00
Repeat read of target register: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Which makes me think that there's something wrong with the configuration of the registers.
I also ran the test_loragw_spi, with this result:
Beginning of test for loragw_spi.c
data received (simple read): 7
End of test for loragw_spi.c
and the test_loragw_reg, with this result:
Beginning of test for loragw_reg.c
Start of register verification
+++MATCH+++ reg number 0 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 1 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 2 read: 103 (67) default: 103 (67)
+++MATCH+++ reg number 3 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 4 read: 53 (35) default: 0 (0)
+++MATCH+++ reg number 5 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 6 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 7 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 8 read: 8 (8) default: 0 (0)
+++MATCH+++ reg number 9 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 10 read: 165 (a5) default: 0 (0)
+++MATCH+++ reg number 11 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 12 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 13 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 14 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 15 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 16 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 17 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 18 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 19 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 20 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 21 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 22 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 23 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 24 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 25 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 26 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 27 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 28 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 29 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 30 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 31 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 32 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 33 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 34 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 35 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 36 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 37 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 38 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 39 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 40 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 41 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 42 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 43 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 44 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 45 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 46 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 47 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 48 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 49 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 50 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 51 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 52 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 53 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 54 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 55 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 56 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 57 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 58 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 59 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 60 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 61 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 62 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 63 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 64 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 65 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 66 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 67 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 68 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 69 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 70 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 71 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 72 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 73 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 74 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 75 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 76 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 77 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 78 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 79 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 80 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 81 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 82 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 83 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 84 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 85 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 86 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 87 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 88 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 89 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 90 read: 7 (7) default: 7 (7)
+++MATCH+++ reg number 91 read: 240 (f0) default: 240 (f0)
+++MATCH+++ reg number 92 read: -384 (fffffe80) default: -384 (fffffe80)
+++MATCH+++ reg number 93 read: -128 (ffffff80) default: -128 (ffffff80)
+++MATCH+++ reg number 94 read: 128 (80) default: 128 (80)
+++MATCH+++ reg number 95 read: 384 (180) default: 384 (180)
+++MATCH+++ reg number 96 read: -384 (fffffe80) default: -384 (fffffe80)
+++MATCH+++ reg number 97 read: -128 (ffffff80) default: -128 (ffffff80)
+++MATCH+++ reg number 98 read: 128 (80) default: 128 (80)
+++MATCH+++ reg number 99 read: 384 (180) default: 384 (180)
+++MATCH+++ reg number 100 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 101 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 102 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 103 read: 7 (7) default: 7 (7)
+++MATCH+++ reg number 104 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 105 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 106 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 107 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 108 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 109 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 110 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 111 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 112 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 113 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 114 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 115 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 116 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 117 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 118 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 119 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 120 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 121 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 122 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 123 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 124 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 125 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 126 read: 4 (4) default: 4 (4)
+++MATCH+++ reg number 127 read: 5 (5) default: 5 (5)
+++MATCH+++ reg number 128 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 129 read: 4092 (ffc) default: 4092 (ffc)
+++MATCH+++ reg number 130 read: 7 (7) default: 7 (7)
+++MATCH+++ reg number 131 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 132 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 133 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 134 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 135 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 136 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 137 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 138 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 139 read: 29 (1d) default: 29 (1d)
+++MATCH+++ reg number 140 read: 9 (9) default: 9 (9)
+++MATCH+++ reg number 141 read: 2 (2) default: 2 (2)
+++MATCH+++ reg number 142 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 143 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 144 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 145 read: 2 (2) default: 2 (2)
+++MATCH+++ reg number 146 read: 10 (a) default: 10 (a)
+++MATCH+++ reg number 147 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 148 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 149 read: 8 (8) default: 8 (8)
+++MATCH+++ reg number 150 read: 2 (2) default: 2 (2)
+++MATCH+++ reg number 151 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 152 read: 255 (ff) default: 255 (ff)
+++MATCH+++ reg number 153 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 154 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 155 read: 8 (8) default: 8 (8)
+++MATCH+++ reg number 156 read: 7 (7) default: 7 (7)
+++MATCH+++ reg number 157 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 158 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 159 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 160 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 161 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 162 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 163 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 164 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 165 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 166 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 167 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 168 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 169 read: 32 (20) default: 32 (20)
+++MATCH+++ reg number 170 read: 100 (64) default: 100 (64)
+++MATCH+++ reg number 171 read: 100 (64) default: 100 (64)
+++MATCH+++ reg number 172 read: 7 (7) default: 7 (7)
+++MATCH+++ reg number 173 read: 5 (5) default: 5 (5)
+++MATCH+++ reg number 174 read: 8 (8) default: 8 (8)
+++MATCH+++ reg number 175 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 176 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 177 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 178 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 179 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 180 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 181 read: 1 (1) default: 0 (0)
+++MATCH+++ reg number 182 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 183 read: 61447 (f007) default: 0 (0)
###MISMATCH### reg number 184 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 185 read: 8 (8) default: 2 (2)
###MISMATCH### reg number 186 read: 6 (6) default: 0 (0)
###MISMATCH### reg number 187 read: 31 (1f) default: 0 (0)
###MISMATCH### reg number 188 read: -128 (ffffff80) default: 0 (0)
+++MATCH+++ reg number 189 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 190 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 191 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 192 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 193 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 194 read: 0 (0) default: 5 (5)
+++MATCH+++ reg number 195 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 196 read: 1 (1) default: 1 (1)
###MISMATCH### reg number 197 read: 1 (1) default: 0 (0)
+++MATCH+++ reg number 198 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 199 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 200 read: 128 (80) default: 0 (0)
###MISMATCH### reg number 201 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 202 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 203 read: 8 (8) default: 2 (2)
###MISMATCH### reg number 204 read: 32799 (801f) default: 10 (a)
###MISMATCH### reg number 205 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 206 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 207 read: 128 (80) default: 10 (a)
###MISMATCH### reg number 208 read: 1 (1) default: 3 (3)
###MISMATCH### reg number 209 read: 0 (0) default: 29 (1d)
###MISMATCH### reg number 210 read: 0 (0) default: 36 (24)
+++MATCH+++ reg number 211 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 212 read: 0 (0) default: 2 (2)
###MISMATCH### reg number 213 read: 0 (0) default: 1 (1)
+++MATCH+++ reg number 214 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 215 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 216 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 217 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 218 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 219 read: 0 (0) default: 8 (8)
###MISMATCH### reg number 220 read: 0 (0) default: 3 (3)
+++MATCH+++ reg number 221 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 222 read: 0 (0) default: 7 (7)
###MISMATCH### reg number 223 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 224 read: 0 (0) default: 255 (ff)
###MISMATCH### reg number 225 read: 0 (0) default: 128 (80)
+++MATCH+++ reg number 226 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 227 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 228 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 229 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 230 read: 6 (6) default: 0 (0)
###MISMATCH### reg number 231 read: 1 (1) default: 0 (0)
+++MATCH+++ reg number 232 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 233 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 234 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 235 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 236 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 237 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 238 read: 1145339392 (44447e00) default: 0 (0)
###MISMATCH### reg number 239 read: 68 (44) default: 0 (0)
###MISMATCH### reg number 240 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 241 read: 2 (2) default: 0 (0)
###MISMATCH### reg number 242 read: 0 (0) default: 1 (1)
+++MATCH+++ reg number 243 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 244 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 245 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 246 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 247 read: 0 (0) default: 1 (1)
###MISMATCH### reg number 248 read: 4092 (ffc) default: 0 (0)
###MISMATCH### reg number 249 read: 2 (2) default: 0 (0)
###MISMATCH### reg number 250 read: 7 (7) default: 0 (0)
###MISMATCH### reg number 251 read: 240 (f0) default: 0 (0)
+++MATCH+++ reg number 252 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 253 read: 128 (80) default: 0 (0)
###MISMATCH### reg number 254 read: 31 (1f) default: 0 (0)
###MISMATCH### reg number 255 read: 128 (80) default: 0 (0)
+++MATCH+++ reg number 256 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 257 read: 1 (1) default: 0 (0)
+++MATCH+++ reg number 258 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 259 read: 0 (0) default: 1 (1)
+++MATCH+++ reg number 260 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 261 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 262 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 263 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 264 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 265 read: 14 (e) default: 2 (2)
###MISMATCH### reg number 266 read: 1 (1) default: 4 (4)
###MISMATCH### reg number 267 read: 0 (0) default: 2 (2)
###MISMATCH### reg number 268 read: 8 (8) default: 4 (4)
###MISMATCH### reg number 269 read: 31 (1f) default: 0 (0)
+++MATCH+++ reg number 270 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 272 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 273 read: 128 (80) default: 0 (0)
###MISMATCH### reg number 274 read: 1 (1) default: 0 (0)
+++MATCH+++ reg number 275 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 276 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 277 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 278 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 279 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 280 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 281 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 282 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 283 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 284 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 285 read: 14 (e) default: 0 (0)
+++MATCH+++ reg number 286 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 287 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 288 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 289 read: 2113929216 (7e000000) default: 0 (0)
###MISMATCH### reg number 290 read: 4 (4) default: 0 (0)
###MISMATCH### reg number 291 read: 4 (4) default: 0 (0)
###MISMATCH### reg number 292 read: 4 (4) default: 0 (0)
###MISMATCH### reg number 293 read: 4 (4) default: 0 (0)
###MISMATCH### reg number 294 read: 4 (4) default: 0 (0)
###MISMATCH### reg number 295 read: 4 (4) default: 0 (0)
###MISMATCH### reg number 296 read: 4 (4) default: 0 (0)
+++MATCH+++ reg number 297 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 298 read: 4 (4) default: 0 (0)
+++MATCH+++ reg number 299 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 300 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 301 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 302 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 303 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 304 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 305 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 306 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 307 read: 1 (1) default: 0 (0)
###MISMATCH### reg number 308 read: 1 (1) default: 0 (0)
###MISMATCH### reg number 309 read: 3 (3) default: 0 (0)
+++MATCH+++ reg number 310 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 311 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 312 read: 7 (7) default: 0 (0)
+++MATCH+++ reg number 313 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 314 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 315 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 316 read: 1 (1) default: 0 (0)
+++MATCH+++ reg number 317 read: 1 (1) default: 1 (1)
+++MATCH+++ reg number 318 read: 0 (0) default: 0 (0)
+++MATCH+++ reg number 319 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 320 read: 2333 (91d) default: 0 (0)
###MISMATCH### reg number 321 read: 6 (6) default: 0 (0)
###MISMATCH### reg number 322 read: 1 (1) default: 0 (0)
###MISMATCH### reg number 323 read: 10 (a) default: 0 (0)
+++MATCH+++ reg number 324 read: 0 (0) default: 0 (0)
###MISMATCH### reg number 325 read: 2 (2) default: 0 (0)
End of register verification
IMPLICIT_PAYLOAD_LENGHT = 0 (should be 197)
FRAME_SYNCH_PEAK2_POS = 2 (should be 11)
PREAMBLE_SYMB1_NB = 10 (should be 49253)
ADJUST_MODEM_START_OFFSET_SF12_RDX4 = 4092 (should be 3173)
IF_FREQ_1 = -128 (should be -1947)
End of test for loragw_reg.c
Can you help me figure out what is wrong and how I fix it?

Before using the LoRa concentrator (iC880A-SPI) for any purpose you must reset it through one of the Raspberty PI's GPIO. (You should connect the reset pin of the board to a GPIO port) This is explained in chapter 4.1 of the readme file of the packet_forwarder app.
Did you reset the concentrator? If not, then that could be the reason of your error message.

Related

How do I chart categorical, cumulative, and time-dependent data?

I have a bunch of time-dependent data, non-decreasing and right-continuous, always with come category involved, that can be repeated. I am looking for a sort of a variable width-bar chart, or cascade chart, flipped on it's side, from the right. For example,
set term postscript eps enhanced
set output "so.eps"
$Data <<EOD
# date source reg sic pic total
2000-07-25 2000glider C-FJSN 8 0 216
2000-07-28 2000glider C-FJSN 10 0 226
2000-07-28 2000glider C-FJSN 11 0 237
2000-07-28 2000glider C-GCLB 4 0 241
2000-07-29 2000glider C-GCLY 3 0 244
2000-07-29 2000glider C-GCLY 2 0 246
2000-07-29 2000glider C-GCLY 17 0 263
2000-07-30 2000glider C-GCLB 15 0 278
2000-07-30 2000glider C-GCLB 0 13 291
2000-07-30 2000glider C-GCLK 11 0 302
2000-07-30 2000glider C-FJSN 0 16 318
2000-07-30 2000glider C-GCLB 0 10 328
2000-08-02 2000glider C-GQRT 0 13 341
2000-08-04 2000glider C-GCLY 0 11 352
2000-08-05 2000glider C-GCLB 12 0 364
2000-08-05 2000glider C-GCLB 0 12 376
2000-08-06 2000glider C-GCLB 0 11 387
2000-08-07 2000glider C-GFMB 0 12 399
2000-08-07 2000glider C-GCMB 0 11 410
2000-08-08 2000glider C-GCLK 0 12 422
2000-08-09 2000glider C-GCLB 14 0 436
2000-08-09 2000glider C-GCLB 0 9 445
2000-08-10 2000glider C-GCLL 0 10 455
EOD
set monochrome
set xdata time
set timefmt "%Y-%m-%d"
set xtics format "%Y-%m-%d" rotate by -30
set ylabel "hours"
set grid
unset key
unset border
plot $Data using 1:($6/60) with fillsteps lw 2, \
$Data using 1:($6/60):3 with labels
Which gives,
I'm trying to create like a cumulative distribution function, where hours, in this case, are added. I want the line to go to zero on the left and the maximum value on the right. The labels, instead of printing, should be in the key and mapped to the data, grouped with other consecutive data, from the right. Is there such a plot, and how to I create it?
I have full control over the input, so I was thinking maybe an inverse-transform and rotate would be easier?
Not sure if I fully understood all your points correctly.
Maybe the following script might bring you closer to what you want.
Update:
If you want color bars for intervals then you could use the plotting style with boxxyerror (check help boxxy).
with boxxy requires either 4 or 6 columns. 4 columns would be (x):(y):(dx):(dy) for a box centered at x,y with +/-dx and +/-dy.
sum up your durations which are either in column 4 or 5 in the variable total. No need for column 6.
the difference dx=43200 (i.e. half a day in seconds)
There are different ways of plottings steps.
Script:
### cumulative plot with color code
reset session
$Data <<EOD
# date source reg sic pic total
2000-07-25 2000glider C-FJSN 8 0 216
2000-07-28 2000glider C-FJSN 10 0 226
2000-07-28 2000glider C-FJSN 11 0 237
2000-07-28 2000glider C-GCLB 4 0 241
2000-07-29 2000glider C-GCLY 3 0 244
2000-07-29 2000glider C-GCLY 2 0 246
2000-07-29 2000glider C-GCLY 17 0 263
2000-07-30 2000glider C-GCLB 15 0 278
2000-07-30 2000glider C-GCLB 0 13 291
2000-07-30 2000glider C-GCLK 11 0 302
2000-07-30 2000glider C-FJSN 0 16 318
2000-07-30 2000glider C-GCLB 0 10 328
2000-08-02 2000glider C-GQRT 0 13 341
2000-08-04 2000glider C-GCLY 0 11 352
2000-08-05 2000glider C-GCLB 12 0 364
2000-08-05 2000glider C-GCLB 0 12 376
2000-08-06 2000glider C-GCLB 0 11 387
2000-08-07 2000glider C-GFMB 0 12 399
2000-08-07 2000glider C-GCMB 0 11 410
2000-08-08 2000glider C-GCLK 0 12 422
2000-08-09 2000glider C-GCLB 14 0 436
2000-08-09 2000glider C-GCLB 0 9 445
2000-08-10 2000glider C-GCLL 0 10 455
EOD
# get a unique list from datablock
addToList(list,col) = list.( strstrt(list,'"'.strcol(col).'"') > 0 ? \
'' : ' "'.strcol(col).'"')
Uniqs = ''
stats $Data u (Uniqs=addToList(Uniqs,3)) nooutput
Uniq(i) = word(Uniqs,i)
getIndex(s) = sum [_i=1:words(Uniqs)] s eq word(Uniqs,_i) ? _i : 0
myTimeFmt = "%Y-%m-%d"
set format x myTimeFmt timedate
set xtics format myTimeFmt rotate by -30
set ylabel "hours"
set format y "%tH:%tM" timedate
set grid
set key out reverse Left noautotitle
set style fill solid 0.5
plot total=0 $Data u (timecolumn(1,myTimeFmt)):(dy=($4+$5)*60,total=total+dy) w steps lc "black" dt 3, \
total=0 '' u (timecolumn(1,myTimeFmt)):(dy=($4+$5)*60,total=total+dy,total-dy/2.): \
(43200):(dy/2.):(getIndex(strcol(3))) w boxxy lc var, \
for [i=1:words(Uniqs)] keyentry w boxxy lc i ti Uniq(i)
### end of script
Result:

Postgresql bottleneck neither CPU, network nor I/O

We are testing our application for performance, which is using Postgresql 13 as a database. It is very insert and update heavy and we cannot get more than 65k TPS on the database. But none of the most common bottlenecks do apply (CPU/network/disk IO).
We have also run multiple combinations with pgbench but also those cannot go past 65k.
E.g.
pgbench -i -s 50 -U postgres -h <DB_HOST> -d <DB_NAME>
pgbench -c 64 -j 32 -t 100000 -h <DB_HOST> -U postgres <DB_NAME>
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 50
query mode: simple
number of clients: 64
number of threads: 32
number of transactions per client: 100000
number of transactions actually processed: 6400000/6400000
latency average = 0.976 ms
tps = 65584.664360 (including connections establishing)
tps = 65594.330678 (excluding connections establishing)
(Using more clients resulted in fewer TPS)
The database server has the following specs:
64 Cores (Intel Xeon Gold 6130 (Skylake, 2.10GHz, 2 CPUs/node, 16 cores/CPU))
192 GiB RAM (12 * 16GiB DIMM DDR4 Synchronous Registered (Buffered) 2666 MHz (0.4 ns))
2 * SSD SATA Samsung MZ7KM240HMHQ0D3 (one is used for the WAL and the other for the data)
10 Gbps network link
OS: Debian 11
And we are using the following configuration:
shared_buffers=65551953kB
effective_cache_size=147491895kB
huge_pages=on
min_wal_size=4GB
max_wal_size=16GB
wal_buffers=1GB
work_mem=2GB
maintenance_work_mem=4GB
checkpoint_completion_target=0.9
checkpoint_timeout = 15min
random_page_cost=1.1
bgwriter_flush_after = 2MB
effective_io_concurrency = 200
# Disabled just for performance experiments
fsync = off
synchronous_commit = off
full_page_writes = on
max_worker_processes=64
max_parallel_workers=64
max_parallel_workers_per_gather=10
max_parallel_maintenance_workers=12
When we reach the 65k TPS we have the following resource usage on the server:
Our application:
CPU: 25%
I/O Utilization: 30% resp. 60% (WAL)
Network: in 200Mbps out 125Mbps
pgbench:
CPU: 75%
I/O Utilization: 2% resp. 5% (WAL)
Network: in/out ~500Mbps
We have also temporarily placed the WAL and data into RAM to verify that the disks are not the issue, but this had no impact either.
Does anyone have a guess where our bottleneck might be?
(We have thought about sharding already but would like to use the single server as much as possible)
Edit:
vmstat 1 -S M while running pgbench:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 92009 25 18316 0 0 3 318 405 22 26 11 63 0 0
0 0 0 92009 25 18316 0 0 0 0 261 320 0 0 100 0 0
0 0 0 92009 25 18316 0 0 0 46616 216 257 0 0 100 0 0
45 0 0 92260 25 17996 0 0 0 0 509124 781029 35 13 52 0 0
44 1 0 92252 25 17998 0 0 0 82192 743920 1140285 51 20 30 0 0
50 0 0 92247 25 18003 0 0 0 65564 740366 1152212 52 18 30 0 0
41 0 0 92243 25 18005 0 0 0 0 736052 1138409 50 20 30 0 0
35 0 0 92240 25 18009 0 0 0 0 734265 1138483 50 20 30 0 0
36 0 0 92238 25 18012 0 0 0 264 741315 1152409 52 19 29 0 0
43 0 0 92236 25 18016 0 0 0 36 740374 1147759 51 20 29 0 0
46 0 0 92231 25 18020 0 0 0 163856 737491 1166498 53 19 28 0 0
47 0 0 92228 25 18023 0 0 0 0 741582 1171814 52 19 28 0 0
43 0 0 92223 25 18027 0 0 0 61584 741537 1168119 53 19 28 0 0
46 0 0 92220 25 18030 0 0 0 36 739695 1167456 53 19 28 0 0
43 0 0 92216 25 18034 0 0 0 228 741992 1150333 52 20 29 0 0
38 0 0 92214 25 18036 0 0 0 147464 740589 1166289 52 19 28 0 0
41 0 0 92209 25 18042 0 0 0 0 737148 1162946 52 19 28 0 0
44 0 0 92207 25 18044 0 0 0 2480 741757 1173128 53 19 28 0 0
39 0 0 92205 25 18049 0 0 0 48 740404 1170644 53 19 28 0 0
52 0 0 92201 25 18051 0 0 0 292 739032 1159037 52 19 28 0 0
42 1 0 92198 25 18054 0 0 0 20072 740101 1165594 52 20 28 0 0
51 0 0 92194 25 18059 0 0 0 45464 738055 1165382 53 19 28 0 0
41 0 0 92190 25 18062 0 0 0 0 742838 1172377 53 19 28 0 0
45 0 0 92185 25 18067 0 0 0 36 740704 1174534 53 19 28 0 0
50 0 0 92182 25 18069 0 0 0 92 741691 1150716 52 19 28 0 0
42 0 0 92177 25 18073 0 0 0 28 740220 1168488 53 18 28 0 0
44 0 0 92174 25 18077 0 0 0 0 738818 1164769 53 19 28 0 0
46 0 0 92172 25 18080 0 0 0 0 740720 1169902 53 19 28 0 0
46 0 0 92166 25 18083 0 0 0 90404 592524 945810 42 15 43 0 0
45 0 0 92161 25 18087 0 0 0 3884 746310 1159898 52 19 28 0 0
49 0 0 92157 25 18090 0 0 0 20 747242 1177750 53 19 28 0 0
36 0 0 92152 25 18094 0 0 0 0 744477 1173832 53 19 28 0 0
46 0 0 92149 25 18098 0 0 0 0 746194 1172700 53 19 28 0 0
39 0 0 92147 26 18101 0 0 0 49768 745651 1177462 54 18 28 0 0
43 0 0 92143 26 18105 0 0 0 212 744968 1161110 53 19 28 0 0
43 0 0 92138 26 18109 0 0 0 0 743223 1176960 54 19 28 0 0
43 0 0 92135 26 18112 0 0 0 81920 745168 1173574 53 19 28 0 0
48 0 0 92132 26 18116 0 0 0 0 743174 1169255 53 19 28 0 0
48 0 0 92129 26 18120 0 0 0 68 592295 933445 42 15 43 0 0
41 0 0 92124 26 18123 0 0 0 76 740354 1162221 52 19 28 0 0
49 0 0 92120 26 18125 0 0 0 0 738456 1158291 53 19 28 0 0
39 0 0 92117 26 18129 0 0 0 147536 740735 1162479 52 20 28 0 0
49 0 0 92113 26 18133 0 0 0 0 737209 1165532 53 20 28 0 0
49 0 0 92111 26 18137 0 0 0 40 741185 1168133 54 19 28 0 0
45 0 0 92110 26 18140 0 0 0 4000 740693 1141945 52 20 28 0 0
42 0 0 92105 26 18144 0 0 0 0 741857 1168830 53 19 28 0 0
43 0 0 92102 26 18147 0 0 0 8 742546 1168867 54 18 28 0 0
43 0 0 92101 26 18150 0 0 0 147456 741941 1166646 53 19 28 0 0
41 1 0 92097 26 18154 0 0 0 64192 740052 1169040 53 19 28 0 0
48 0 0 92094 26 18158 0 0 0 27484 737224 1139511 52 20 28 0 0
47 0 0 92087 26 18162 0 0 0 0 740821 1165037 53 19 28 0 0
54 0 0 92059 26 18164 0 0 0 4 737109 1155098 53 19 27 0 0
38 0 0 92051 26 18170 0 0 0 147456 701847 1075069 55 20 25 0 0
35 0 0 92064 26 18174 0 0 0 44 723153 1125736 54 19 27 0 0
48 0 0 92056 26 18179 0 0 0 53008 734590 1134838 52 19 29 0 0
46 0 0 92053 26 18183 0 0 0 0 741595 1166891 53 19 28 0 0
46 0 0 92049 26 18186 0 0 0 0 740196 1170838 54 19 27 0 0
31 1 0 92045 26 18191 0 0 0 98304 741800 1170076 54 18 28 0 0
44 0 0 92043 26 18194 0 0 0 49188 733352 1173652 53 20 27 0 0
43 0 0 92028 26 18198 0 0 0 116 733522 1151497 53 20 27 0 0
44 0 0 92037 26 18201 0 0 0 0 730364 1137665 53 19 27 0 0
37 0 0 92035 26 18204 0 0 0 0 742348 1164945 53 19 28 0 0
44 0 0 92031 26 18208 0 0 0 0 739273 1165044 53 19 28 0 0
52 0 0 92028 26 18211 0 0 0 147888 739274 1164496 53 19 28 0 0
50 0 0 92024 26 18215 0 0 0 144 739684 1145210 53 19 28 0 0
50 0 0 92020 26 18219 0 0 0 0 742847 1167779 54 18 28 0 0
38 0 0 92016 26 18223 0 0 0 0 738079 1166580 53 19 28 0 0
36 0 0 92013 26 18226 0 0 0 0 742687 1171101 54 18 27 0 0
48 0 0 92009 26 18229 0 0 0 147500 741536 1166846 53 19 28 0 0
40 0 0 92006 26 18233 0 0 0 94600 740746 1147102 52 20 28 0 0
45 0 0 92001 26 18238 0 0 0 0 741119 1163851 53 19 28 0 0
48 0 0 91999 26 18241 0 0 0 0 740995 1167197 53 19 28 0 0
35 0 0 91996 26 18244 0 0 0 0 742235 1165666 53 19 28 0 0
44 1 0 91993 26 18248 0 0 0 49192 741392 1164506 53 19 28 0 0
43 1 0 91990 26 18251 0 0 0 124876 743695 1144639 52 19 29 0 0
48 0 0 91987 26 18255 0 0 0 24864 737759 1159383 52 20 28 0 0
44 0 0 91983 26 18258 0 0 0 0 740224 1164983 53 19 28 0 0
43 0 0 91980 26 18262 0 0 0 0 741742 1168140 54 19 27 0 0
18 0 0 91976 26 18267 0 0 0 36 737449 1162293 53 19 28 0 0
49 0 0 91973 26 18269 0 0 0 147576 741462 1148048 52 20 28 0 0
43 0 0 91969 26 18274 0 0 0 0 742408 1168332 54 19 27 0 0
43 0 0 91966 26 18277 0 0 0 0 738803 1164992 53 19 28 0 0
39 0 0 91963 26 18280 0 0 0 4 737891 1159372 52 19 28 0 0
43 0 0 91962 26 18283 0 0 0 40 741888 1166835 53 19 28 0 0
48 0 0 91958 26 18287 0 0 0 164144 738677 1145900 52 20 28 0 0
46 0 0 91955 26 18291 0 0 0 0 740956 1165789 53 19 28 0 0
44 0 0 91952 26 18295 0 0 0 0 741055 1166460 53 19 28 0 0
44 0 0 91948 26 18299 0 0 0 8 739414 1165698 53 19 28 0 0
46 0 0 91945 26 18301 0 0 0 48 743218 1165277 53 19 28 0 0
36 0 0 91941 26 18305 0 0 0 208 736320 1134425 51 20 29 0 0
47 0 0 91936 26 18309 0 0 0 239096 739799 1159730 52 19 28 0 0
45 0 0 91932 26 18312 0 0 0 0 742477 1167618 53 20 28 0 0
45 0 0 91928 26 18316 0 0 0 0 736442 1159690 52 20 28 0 0
47 0 0 91926 26 18319 0 0 0 76 737145 1157620 52 20 28 0 0
48 0 0 91921 26 18323 0 0 0 64 739999 1146323 52 19 29 0 0
50 0 0 91918 26 18326 0 0 0 197176 739590 1159797 52 19 28 0 0
50 0 0 91915 26 18330 0 0 0 0 740533 1166111 53 19 28 0 0
52 0 0 91911 26 18334 0 0 0 0 739776 1161328 52 20 28 0 0
42 0 0 91907 26 18338 0 0 0 60 590783 929545 41 16 43 0 0
39 0 0 91904 26 18341 0 0 0 4248 744434 1161062 52 19 29 0 0
41 1 0 91900 26 18345 0 0 0 114688 741817 1163511 53 19 28 0 0
14 0 0 91928 26 18349 0 0 0 32768 598242 996868 43 15 42 0 0
0 0 0 91951 26 18349 0 0 0 0 41914 84357 3 1 96 0 0
0 0 0 91952 26 18349 0 0 0 36 174 204 0 0 100 0 0
0 0 0 91954 26 18349 0 0 0 276 7897 13403 0 0 99 0 0
0 0 0 91954 26 18349 0 0 0 0 1911 3678 0 0 100 0 0
0 0 0 91954 26 18349 0 0 0 147456 330 351 0 0 100 0 0
Edit:
The same pgbench benchmark as above gave about 68k when it was run on the same system as the database and select only 540k (507k from a remote system).
Is CPU:75% user or user + system?
Anyway, 75% of OS CPU with hyper-threading means all cores 100% busy.
You use simple protocol tpc-b which is stressing network and context switches.
See https://franckpachot.medium.com/do-you-know-what-you-are-measuring-with-pgbench-d8692a33e3d6

Why does YugaByteDB YSQL select query return unexpected bytes when using bytea data type?

I am trying to store some binary data into yugabytedb on my laptop in minikube, so I used the bytea datatype as the documentation says.
But when it comes to retrieving the binary data back using a select query, the bytes returned are very different from what I expect!
What could be the cause of this?
I got a solution
Here was my code:
/*
===============================
GOLANG CODE REGISTERING A USER:
================================
*/
db := dbconnect()
defer db.Close()
log.Println("Registration Server says: user.Photo = ", user.Photo[:100])
usrInsert := fmt.Sprintf("INSERT INTO users (user_id,
username, Phone, Email, Nationality, Photo, pxwrd)
VALUES ('%s','%s','%s','%s','%s','%x','%s')",
user.user_id, user.username, user.Phone,
user.Email, user.Nationality, user.Photo,
encriptedpassword)
_, err := db.Exec(usrInsert)
if err != nil {
fmt.Println(err.Error());
}
/*
=============================================
OUTPUT OF 'log.Println' ABOVE WAS:
=============================================
Registration Server says: user.Photo = [1 0 0 0 0 0 6
213 194 0 0 0 24 255 216 255 224 0 16 74 70 73 70 0 1 2 1
1 44 1 44 0 0 255 225 16 115 69 120 105 102 0 0 77 77 0 42
0 0 0 8 0 11 1 15 0 2 0 0 0 18 0 0 0 146 1 16 0 2 0 0 0 10
0 0 0 164 1 18 0 3 0 0 0 1 0 1 0 0 1 26 0 5 0 0 0 1 0 0 0]
*/
/*
=============================
GOLANG CODE FOR USER LOGIN:
=============================
Note: the user profile Photo is
saved as 'bytea' data type
*/
//select query for loging in
selecQuery := fmt.Sprintf("SELECT * FROM users WHERE
username='%s' AND pxwrd='%x' ",
uname, encriptedpassword)
queryResult, err := db.Query(selecQuery)
if err != nil {
fmt.Println(err.Error())
}
defer queryResult.Close()
userExists := false
for queryResult.Next() {
userExists = true
var UserX rs_utils.User
var cnt, psw string
err = queryResult.Scan(&cnt, &UserX.User_id,
&UserX.Username, &UserX.Phone, &UserX.Email,
&UserX.Nationality, &UserX.Photo, &psw)
if err != nil {
log.Println("!! Error: ", err)
break
}
log.Println("UserX.Photo, psw :\n", UserX.Photo[:100], psw)
//...
/...
}
/*
==============================
OUTPUT OF 'log.Println' ABOVE:
==============================
UserX.Photo, psw :
[48 49 48 48 48 48 48 48 48 48 48 48 49 53 97 98 48 53 48 48 48
48 48 48 50 97 56 57 53 48 52 101 52 55 48 100 48 97 49 97 48 97
48 48 48 48 48 48 48 100 52 57 52 56 52 52 53 50 48 48 48 48 48
52 54 99 48 48 48 48 48 50 55 102 48 56 48 54 48 48 48 48 48 48
50 100 54 50 52 53 53 51 48 48 48 48 48
48 48 49] 8ae5776067290c4712fa454006c8ec6
*/
As you can see, the retrieved binary data was very different from
what was inserted.
The cause:
usrInsert := fmt.Sprintf("INSERT INTO users (user_id, username,
Phone, Email, Nationality, Photo, pxwrd)
VALUES ('%s','%s','%s','%s','%s','%x','%s')",
user.user_id, user.username, user.Phone,
user.Email, user.Nationality, user.Photo,
encriptedpassword)
_, err := db.Exec(usrInsert)
//AND
selecQuery := fmt.Sprintf("SELECT * FROM users WHERE
username='%s' AND pxwrd='%x' ", uname, encriptedpassword)
queryResult, err := db.Query(selecQuery)
//Notice the string formatting in the queries.
SOLUTION:
I replaced the above lines of code with:
_, err := db.Exec(`INSERT INTO users (user_id, username,
Phone, Email, Nationality, Photo, pxwrd)
VALUES ($1, $2, $3, $4, $5, $6, $7)`,
user.user_id, user.username, user.Phone, user.Email,
user.Nationality, user.Photo, encriptedpassword)
//AND
queryResult, err := db.Query(`SELECT * FROM users WHERE
username=$1 AND pxwrd=$2 `, uname, encriptedpassword)
respectively.

Triangular Multiplication Table

I'm working on a program that's supposed to write out the multiplication table as shown in the picture.
This is what I've done
A = (1:10)'*(1:10);
tril (A)
And this is my output. Is there a way I can do this without the zeros?
Or should I go with a different approach? Any help is greatly appreciated.
1 0 0 0 0 0 0 0 0 0
2 4 0 0 0 0 0 0 0 0
3 6 9 0 0 0 0 0 0 0
4 8 12 16 0 0 0 0 0 0
5 10 15 20 25 0 0 0 0 0
6 12 18 24 30 36 0 0 0 0
7 14 21 28 35 42 49 0 0 0
8 16 24 32 40 48 56 64 0 0
9 18 27 36 45 54 63 72 81 0
10 20 30 40 50 60 70 80 90 100
Here's one way:
A=tril((1:10)'*(1:10))
A(A==0)=NaN;
S=num2str(A);
S(S==78|S==97)=' '
The second line distinguishes plain old '0' from a pesky '0' in, say, '20'.
The third line converts the array to a string.
The last line replaces capital 'N' (character 78) and lowercase 'a' (character 97) with blank space.
Your approach is good, but if you want to avoid the zeros you want strings, not numbers. For example,
>> n = 10;
>> char(arrayfun(#(k) {sprintf('%i ', k:k:k^2)}, 1:n).')
ans =
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49
8 16 24 32 40 48 56 64
9 18 27 36 45 54 63 72 81
10 20 30 40 50 60 70 80 90 100
How it works
sprintf('%i ', k:k:k^2) generates each row of the table as a string. cellfun is used to iterate over all rows. The rows are packed into a cell array of strings, and that cell array is converted to a char matrix, which automatically pads with spaces.

Quantize dct cofficents in matlab

hello i need to perform quantization to dct cofficents for an image, for a block
size of 8*8 pixles in matlab. can you help me with the syntax, thank you.
There is a built-in function in MATLAB for DCT.
You need the signal processing tool box. Type 'ver' (without quotes) in the MATLAB command to see if you have it.
The code:
image = image; % define your image
[m,n] = size(image); % get size of your image
imvector = reshape(image, m*n, 1); % reshape your image to a vector to compute DCT
imdct = dct(imvector); % compute DCT
imagedct = reshape(imdct,m,n); \ reshape result back to original form of your image
There is an example in the help file as well which is very nice:
I = imread('cameraman.tif');
I = im2double(I);
T = dctmtx(8);
dct = #(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct);
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
B2 = blockproc(B,[8 8],#(block_struct) mask .* block_struct.data);
invdct = #(block_struct) T' * block_struct.data * T;
I2 = blockproc(B2,[8 8],invdct);
imshow(I), figure, imshow(I2)
To quantize DCT coefficients, you simply divide each coefficient by a quantization term and round to integers. The quantization terms are often unique for each coefficient, and are stored in a quantization matrix.
Wikipedia has a nice example. Here is how to implement that example in Matlab.
coef = [
-415 -33 -58 35 58 -51 -15 -12;
5 -34 49 18 27 1 -5 3;
-46 14 80 -35 -50 19 7 -18;
-53 21 34 -20 2 34 36 12;
9 -2 9 -5 -32 -15 45 37;
-8 15 -16 7 -8 11 4 7;
19 -28 -2 -26 -2 7 -44 -21;
18 25 -12 -44 35 48 -37 -3
];
quant = [
16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99
];
quantCoef = round(coef ./ quant)
quantCoef =
-26 -3 -6 2 2 -1 0 0
0 -3 4 1 1 0 0 0
-3 1 5 -1 -1 0 0 0
-4 1 2 -1 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
clc
clear all
close all
image=imread('Water lilies.jpg');
Q=[8 36 36 36 39 45 52 65;
36 36 36 37 41 47 56 68;
36 36 38 42 47 54 64 78;
36 37 42 50 59 69 81 98;
39 41 47 54 73 89 108 130;
45 47 54 69 89 115 144 178;
53 56 64 81 108 144 190 243;
65 68 78 98 130 178 243 255];
GrayImage=rgb2gray(image);
NewImage=uint8(zeros(size(GrayImage)));
Q=uint32(Q);
for i=1:size(GrayImage,1)/8
for j=1:size(GrayImage,2)/8
block=GrayImage(((i-1)*8)+1:((i-1)*8)+8,((j-1)*8)+1:((j-1)*8)+8);
dct=dct2(block);
dct=uint32(dct);
a=dct./Q;
z=a.*Q;
idct=idct2(z);
NewImage(((i-1)*8)+1:((i-1)*8)+8,((j-1)*8)+1:((j-1)*8)+8)=uint8(idct);
end
end
imwrite(NewImage,'NewImage.jpg');
GrayImage=double(GrayImage);
NewImage=double(NewImage);
MSE=0;
for i=1:size(GrayImage,1)
for j=1:size(GrayImage,2)
d=(GrayImage(i,j)-NewImage(i,j))^2;
MSE=d+MSE;
end
end