How to use ping method of main Package

Best Selenoid code snippet using main.ping

diagI2c.go

Source:diagI2c.go Github

copy

Full Screen

...77 var result bool78 fmt.Printf("\n%15s|%25s|%10s|%10s|%10s|%10s|%6s|%35s\n", "function", "parameter", "units", "value", "min", "max", "result", "description")79 fmt.Printf("---------------|-------------------------|----------|----------|----------|----------|------|-----------------------------------\n")80 /* diagTest: i2c mon81 check that all i2c monitoring pins read high, stuck high pins will be discovered during i2c ping tests82 */83 pinstate, _ := gpioGet("I2C1_SCL_MON")84 r = CheckPassB(pinstate, true)85 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c1_scl_mon", "-", pinstate, i2cmon_min, i2cmon_max, r, "check mon pin is high")86 pinstate, _ = gpioGet("I2C1_SDA_MON")87 r = CheckPassB(pinstate, true)88 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c1_sda_mon", "-", pinstate, i2cmon_min, i2cmon_max, r, "check mon pin is high")89 pinstate, _ = gpioGet("I2C2_SCL_MON")90 r = CheckPassB(pinstate, true)91 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c2_scl_mon", "-", pinstate, i2cmon_min, i2cmon_max, r, "check mon pin is high")92 pinstate, _ = gpioGet("I2C2_SDA_MON")93 r = CheckPassB(pinstate, true)94 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c2_sda_mon", "-", pinstate, i2cmon_min, i2cmon_max, r, "check mon pin is high")95 /* diagTest: host i2c96 enable host access to main_i2c bus and check that bmc can access mfg eeprom on cpu card97 repeat with fru_i2c bus98 */99 gpioSet("CPU_TO_MAIN_I2C_EN", true)100 time.Sleep(50 * time.Millisecond)101 result, _ = diagI2cPing(0x00, 0x51, 0x00, 1)102 r = CheckPassB(result, true)103 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_main_i2c_en_on", "-", result, i2cping_response_min, i2cping_response_max, r, "enable host bus, ping host eeprom")104 gpioSet("CPU_TO_MAIN_I2C_EN", false)105 time.Sleep(50 * time.Millisecond)106 result, _ = diagI2cPing(0x00, 0x51, 0x00, 1)107 r = CheckPassB(result, false)108 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_main_i2c_en_off", "-", result, i2cping_noresponse_min, i2cping_noresponse_max, r, "disable host bus, ping host eeprom")109 gpioSet("CPU_TO_FRU_I2C_EN", true)110 time.Sleep(50 * time.Millisecond)111 result, _ = diagI2cPing(0x01, 0x51, 0x00, 1)112 r = CheckPassB(result, true)113 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_fru_i2c_en_on", "-", result, i2cping_response_min, i2cping_response_max, r, "enable host bus, ping host eeprom")114 gpioSet("CPU_TO_FRU_I2C_EN", false)115 time.Sleep(50 * time.Millisecond)116 result, _ = diagI2cPing(0x01, 0x51, 0x00, 1)117 r = CheckPassB(result, false)118 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_fru_i2c_en_off", "-", result, i2cping_noresponse_min, i2cping_noresponse_max, r, "disable host bus, ping host eeprom")119 time.Sleep(100 * time.Millisecond)120 /* diagTest: i2c power cycle121 disable i2c power and check that i2c devices cannot be accessed122 enable i2c power and check that i2c devices can be accessed123 */124 gpioSet("P3V3_I2C_EN", false)125 gpioSet("CPU_TO_MAIN_I2C_EN", true)126 time.Sleep(50 * time.Millisecond)127 result_s, _ := diagI2cPing(0x00, 0x74, 0x00, 1)128 r_s := CheckPassB(result, false)129 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_i2c_en_off", "-", result_s, i2cping_noresponse_min, i2cping_noresponse_max, r_s, "disable i2c power, ping main_mux0")130 gpioSet("P3V3_I2C_EN", true)131 time.Sleep(50 * time.Millisecond)132 result, _ = diagI2cPing(0x00, 0x74, 0x00, 1)133 r = CheckPassB(result, true)134 diagI2cWriteOffsetByte(0x00, 0x74, 0x06, 0xdf)135 time.Sleep(50 * time.Millisecond)136 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_i2c_en_off", "-", result_s, i2cping_noresponse_min, i2cping_noresponse_max, r_s, "disable i2c power, ping main_mux0")137 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_i2c_en_on", "-", result, i2cping_response_min, i2cping_response_max, r, "enable i2c power, ping main_mux0")138 gpioSet("CPU_TO_MAIN_I2C_EN", false)139 /* diagTest: i2c resets140 activate i2c reset and validate associated devices cannot be accessed141 */142 gpioSet("MAIN_I2C_MUX_RST_L", false)143 time.Sleep(50 * time.Millisecond)144 result, _ = diagI2cPing(0x00, 0x76, 0x00, 1)145 r = CheckPassB(result, false)146 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "main_i2c_mux_rst_l_on", "-", result, i2cping_noresponse_min, i2cping_noresponse_max, r, "enable reset, ping main_mux0")147 gpioSet("MAIN_I2C_MUX_RST_L", true)148 time.Sleep(50 * time.Millisecond)149 result, _ = diagI2cPing(0x00, 0x76, 0x00, 1)150 r = CheckPassB(result, true)151 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "main_i2c_mux_rst_l_off", "-", result, i2cping_response_min, i2cping_response_max, r, "disable reset, ping main_mux0")152 gpioSet("FRU_I2C_MUX_RST_L", false)153 time.Sleep(50 * time.Millisecond)154 result, _ = diagI2cPing(0x01, 0x72, 0x00, 1)155 r = CheckPassB(result, false)156 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "fru_i2c_mux_rst_l_on", "-", result, i2cping_noresponse_min, i2cping_noresponse_max, r, "enable reset, ping fru_mux0")157 gpioSet("FRU_I2C_MUX_RST_L", true)158 time.Sleep(50 * time.Millisecond)159 result, _ = diagI2cPing(0x01, 0x72, 0x00, 1)160 r = CheckPassB(result, true)161 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "fru_i2c_mux_rst_l_off", "-", result, i2cping_response_min, i2cping_response_max, r, "disable reset, ping fru_mux0")162 /* diagTest: P3V3_FAN_EN power cycle163 disable fan board 3.3V power and check that i2c devices cannot be accessed164 enable fan board 3.3Vpower and check that i2c devices can be accessed165 */166 gpioSet("P3V3_FAN_EN", false)167 time.Sleep(50 * time.Millisecond)168 diagI2cWrite1Byte(0x01, 0x72, 0x04)169 time.Sleep(10 * time.Millisecond)170 diagI2cWrite1Byte(0x01, 0x20, 0x00)171 result, _ = diagI2cPing(0x01, 0x20, 0x00, 1)172 r = CheckPassB(result, false)173 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_fan_en_off", "-", result, i2cping_response_min, i2cping_response_max, r, "disable fan3.3V, ping fan brd gpio")174 gpioSet("P3V3_FAN_EN", true)175 time.Sleep(50 * time.Millisecond)176 diagI2cWrite1Byte(0x01, 0x20, 0x00)177 result, _ = diagI2cPing(0x01, 0x20, 0x00, 1)178 r = CheckPassB(result, true)179 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_fan_en_on", "-", result, i2cping_response_min, i2cping_response_max, r, "enable fan3.3V, ping fan brd gpio")180 diagI2cWrite1Byte(0x01, 0x72, 0x00)181 /* diagTest: i2c devices182 check all i2c devices are accessible183 */184 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)185 r = CheckPassB(result, true)186 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_main_mux0", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")187 diagI2cWrite1Byte(0x00, 0x76, 0x01)188 time.Sleep(10 * time.Millisecond)189 result, _ = diagI2cPing(0x00, ucd9090dAdr, 0x00, 10)190 r = CheckPassB(result, true)191 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_ucd9090", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")192 diagI2cWrite1Byte(0x00, 0x76, 0x02)193 time.Sleep(10 * time.Millisecond)194 diagI2cWrite1Byte(0x00, ledgpiodAdr, 0x00)195 result, _ = diagI2cPing(0x00, ledgpiodAdr, 0x00, 10)196 r = CheckPassB(result, true)197 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_led_pca9539", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")198 diagI2cWrite1Byte(0x00, 0x76, 0x04)199 time.Sleep(10 * time.Millisecond)200 diagI2cWrite1Byte(0x00, 0x27, 0x00)201 result, _ = diagI2cPing(0x00, 0x27, 0x00, 10)202 r = CheckPassB(result, true)203 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_board_id_gpio", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")204 diagI2cWrite1Byte(0x00, 0x76, 0x20)205 time.Sleep(10 * time.Millisecond)206 result, _ = diagI2cPing(0x00, 0x6e, 0x00, 10)207 r = CheckPassB(result, true)208 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_th_clk_gen", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")209 diagI2cWrite1Byte(0x00, 0x76, 0x40)210 time.Sleep(10 * time.Millisecond)211 result, _ = diagI2cPing(0x00, 0x21, 0x00, 10)212 r = CheckPassB(result, true)213 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_th1v0_dcdc", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")214 diagI2cWrite1Byte(0x00, 0x76, 0x40)215 time.Sleep(10 * time.Millisecond)216 result, _ = diagI2cPing(0x00, 0x22, 0x00, 10)217 r = CheckPassB(result, true)218 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_thcore_dcdc", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")219 diagI2cWrite1Byte(0x00, 0x76, 0x80)220 time.Sleep(10 * time.Millisecond)221 result, _ = diagI2cPing(0x00, 0x2f, 0x00, 10)222 r = CheckPassB(result, true)223 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_hwm", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")224 diagI2cWrite1Byte(0x00, 0x76, 0x00)225 result, _ = diagI2cPing(0x01, 0x72, 0x00, 10)226 r = CheckPassB(result, true)227 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux0", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")228 diagI2cWrite1Byte(0x01, 0x72, 0x01)229 time.Sleep(10 * time.Millisecond)230 result, _ = diagI2cPing(0x01, 0x50, 0x00, 10)231 r = CheckPassB(result, true)232 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_psu0", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")233 diagI2cWrite1Byte(0x01, 0x72, 0x02)234 time.Sleep(10 * time.Millisecond)235 result, _ = diagI2cPing(0x01, 0x50, 0x00, 10)236 r = CheckPassB(result, true)237 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_psu1", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")238 diagI2cWrite1Byte(0x01, 0x72, 0x04)239 time.Sleep(10 * time.Millisecond)240 diagI2cWrite1Byte(0x01, 0x20, 0x00)241 result, _ = diagI2cPing(0x01, 0x20, 0x00, 10)242 r = CheckPassB(result, true)243 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fan_board", "-", result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")244 diagI2cWrite1Byte(0x01, 0x72, 0x00)245}246func diagI2cCh1Mc() {247 var r string248 var result bool249 // avoid conflicts w/ interrupt handlers.250 // i2c STOP251 sd[0] = 0252 j[0] = I{true, i2c.Write, 0, 0, sd, int(0x99), int(1), 0}253 err := DoI2cRpc()254 if err != nil {255 log.Print(err)256 }257 fmt.Printf("\n%15s|%25s|%10s|%10s|%10s|%10s|%6s|%35s\n", "function", "parameter", "units", "value", "min", "max", "result", "description")258 fmt.Printf("---------------|-------------------------|----------|----------|----------|----------|------|-----------------------------------\n")259 /* diagTest: i2c mon260 check that all i2c monitoring pins read high, stuck high pins will be discovered during i2c ping tests261 */262 pinstate, _ := gpioGet("BMC_I2C0_SCL_MON")263 r = CheckPassB(pinstate, true)264 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c1_scl_mon", "-", pinstate,265 i2cmon_min, i2cmon_max, r, "check mon pin is high")266 pinstate, _ = gpioGet("BMC_I2C0_SDA_MON")267 r = CheckPassB(pinstate, true)268 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c1_sda_mon", "-", pinstate,269 i2cmon_min, i2cmon_max, r, "check mon pin is high")270 pinstate, _ = gpioGet("BMC_I2C1_SCL_MON")271 r = CheckPassB(pinstate, true)272 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c2_scl_mon", "-", pinstate,273 i2cmon_min, i2cmon_max, r, "check mon pin is high")274 pinstate, _ = gpioGet("BMC_I2C1_SDA_MON")275 r = CheckPassB(pinstate, true)276 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c2_sda_mon", "-", pinstate,277 i2cmon_min, i2cmon_max, r, "check mon pin is high")278 // MC additional monitor pins279 pinstate, _ = gpioGet("BMC_I2C2_SCL_MON")280 r = CheckPassB(pinstate, true)281 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c2_scl_mon", "-", pinstate,282 i2cmon_min, i2cmon_max, r, "check mon pin is high")283 pinstate, _ = gpioGet("BMC_I2C2_SDA_MON")284 r = CheckPassB(pinstate, true)285 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "i2c2_sda_mon", "-", pinstate,286 i2cmon_min, i2cmon_max, r, "check mon pin is high")287 /* diagTest: host i2c288 enable host access to main_i2c bus and check that bmc can access mfg eeprom on cpu card289 repeat with fru_i2c bus290 */291 gpioSet("CPU_TO_MAIN_I2C_EN", true)292 time.Sleep(50 * time.Millisecond)293 result, _ = diagI2cPing(0x00, 0x51, 0x00, 1)294 r = CheckPassB(result, true)295 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_main_i2c_en_on", "-", result,296 i2cping_response_min, i2cping_response_max, r, "enable host bus, ping host eeprom")297 gpioSet("CPU_TO_MAIN_I2C_EN", false)298 time.Sleep(50 * time.Millisecond)299 result, _ = diagI2cPing(0x00, 0x51, 0x00, 1)300 r = CheckPassB(result, false)301 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_main_i2c_en_off", "-", result,302 i2cping_noresponse_min, i2cping_noresponse_max, r, "disable host bus, ping host eeprom")303 gpioSet("CPU_TO_FRU_I2C_EN", true)304 time.Sleep(50 * time.Millisecond)305 result, _ = diagI2cPing(0x01, 0x51, 0x00, 1)306 r = CheckPassB(result, true)307 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_fru_i2c_en_on", "-", result,308 i2cping_response_min, i2cping_response_max, r, "enable host bus, ping host eeprom")309 gpioSet("CPU_TO_FRU_I2C_EN", false)310 time.Sleep(50 * time.Millisecond)311 result, _ = diagI2cPing(0x01, 0x51, 0x00, 1)312 r = CheckPassB(result, false)313 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "cpu_to_fru_i2c_en_off", "-", result,314 i2cping_noresponse_min, i2cping_noresponse_max, r, "disable host bus, ping host eeprom")315 time.Sleep(100 * time.Millisecond)316 /* diagTest: i2c power cycle317 disable i2c power and check that i2c devices cannot be accessed318 enable i2c power and check that i2c devices can be accessed319 */320 gpioSet("P3V3_I2C_EN", false)321 gpioSet("CPU_TO_MAIN_I2C_EN", true)322 time.Sleep(50 * time.Millisecond)323 // MC pings the eeprom instead324 result_s, _ := diagI2cPing(0x00, 0x55, 0x00, 1)325 r_s := CheckPassB(result, false)326 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_i2c_en_off", "-", result_s,327 i2cping_noresponse_min, i2cping_noresponse_max, r_s, "disable i2c power, ping local eeprom")328 gpioSet("P3V3_I2C_EN", true)329 time.Sleep(50 * time.Millisecond)330 // MC pings the eeprom instead331 result, _ = diagI2cPing(0x00, 0x55, 0x00, 1)332 r = CheckPassB(result, true)333 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_i2c_en_on", "-", result,334 i2cping_response_min, i2cping_response_max, r, "enable i2c power, ping local eeprom")335 gpioSet("CPU_TO_MAIN_I2C_EN", false)336 /* diagTest: i2c resets337 activate i2c reset and validate associated devices cannot be accessed338 */339 gpioSet("LOCAL_I2C_RESET_L", false)340 time.Sleep(50 * time.Millisecond)341 result, _ = diagI2cPing(0x00, 0x71, 0x00, 1) // MC's main_mux0342 r = CheckPassB(result, false)343 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "main_i2c_mux_rst_l_on", "-", result,344 i2cping_noresponse_min, i2cping_noresponse_max, r, "enable reset, ping main_mux0")345 gpioSet("LOCAL_I2C_RESET_L", true)346 time.Sleep(50 * time.Millisecond)347 result, _ = diagI2cPing(0x00, 0x71, 0x00, 1) // MC's main_mux0348 r = CheckPassB(result, true)349 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "main_i2c_mux_rst_l_off", "-", result,350 i2cping_response_min, i2cping_response_max, r, "disable reset, ping main_mux0")351 gpioSet("FRU_I2C_RESET_L", false)352 time.Sleep(50 * time.Millisecond)353 result, _ = diagI2cPing(0x01, 0x70, 0x00, 1) // MC's fru_mux0354 r = CheckPassB(result, false)355 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "fru_i2c_mux_rst_l_on", "-", result,356 i2cping_noresponse_min, i2cping_noresponse_max, r, "enable reset, ping fru_mux0")357 gpioSet("FRU_I2C_RESET_L", true)358 time.Sleep(50 * time.Millisecond)359 result, _ = diagI2cPing(0x01, 0x70, 0x00, 1) // MC's fru_mux0360 r = CheckPassB(result, true)361 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "fru_i2c_mux_rst_l_off", "-", result,362 i2cping_response_min, i2cping_response_max, r, "disable reset, ping fru_mux0")363 /* diagTest: P3V3_FAN_EN power cycle364 disable fan board 3.3V power and check that i2c devices cannot be accessed365 enable fan board 3.3Vpower and check that i2c devices can be accessed366 */367/****368 Fan diag TBD369 gpioSet("P3V3_FAN_EN", false)370 time.Sleep(50 * time.Millisecond)371 diagI2cWrite1Byte(0x01, 0x72, 0x04)372 time.Sleep(10 * time.Millisecond)373 diagI2cWrite1Byte(0x01, 0x20, 0x00)374 result, _ = diagI2cPing(0x01, 0x20, 0x00, 1)375 r = CheckPassB(result, false)376 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_fan_en_off", "-", result,377 i2cping_response_min, i2cping_response_max, r, "disable fan3.3V, ping fan brd gpio")378 gpioSet("P3V3_FAN_EN", true)379 time.Sleep(50 * time.Millisecond)380 diagI2cWrite1Byte(0x01, 0x20, 0x00)381 result, _ = diagI2cPing(0x01, 0x20, 0x00, 1)382 r = CheckPassB(result, true)383 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "p3v3_fan_en_on", "-", result,384 i2cping_response_min, i2cping_response_max, r, "enable fan3.3V, ping fan brd gpio")385 diagI2cWrite1Byte(0x01, 0x72, 0x00)386*** */387 /* diagTest: i2c devices388 check all i2c devices are accessible389 */390 // MAIN_MUX0391 //392 result, _ = diagI2cPing(0x00, 0x71, 0x00, 10)393 r = CheckPassB(result, true)394 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_main_mux0", "-", result,395 i2cping_response_min, i2cping_response_max, r, "ping device 10x")396 diagI2cWrite1Byte(0x00, 0x71, 0x01)397 time.Sleep(10 * time.Millisecond)398 result, _ = diagI2cPing(0x00, 0x47, 0x00, 10)399 r = CheckPassB(result, true)400 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_LM25066", "-", result,401 i2cping_response_min, i2cping_response_max, r, "ping device 10x")402 diagI2cWrite1Byte(0x00, 0x71, 0x02)403 time.Sleep(10 * time.Millisecond)404 result, _ = diagI2cPing(0x00, 0x7e, 0x00, 10)405 r = CheckPassB(result, true)406 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_ucd9090", "-", result,407 i2cping_response_min, i2cping_response_max, r, "ping device 10x")408 diagI2cWrite1Byte(0x00, 0x71, 0x04)409 time.Sleep(10 * time.Millisecond)410 result, _ = diagI2cPing(0x00, 0x2c, 0x00, 10)411 r = CheckPassB(result, true)412 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_hwmonitor", "-", result,413 i2cping_response_min, i2cping_response_max, r, "ping device 10x")414 diagI2cWrite1Byte(0x00, 0x71, 0x08)415 time.Sleep(10 * time.Millisecond)416 result, _ = diagI2cPingWord(0x00, 0x48, 0x00, 10)417 r = CheckPassB(result, true)418 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_intake_tmp75", "-",419 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")420 diagI2cWrite1Byte(0x00, 0x71, 0x10)421 time.Sleep(10 * time.Millisecond)422 result, _ = diagI2cPing(0x00, 0x50, 0x00, 10)423 r = CheckPassB(result, true)424 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_qsfp_eeprom", "-",425 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")426 diagI2cWrite1Byte(0x00, 0x71, 0x20)427 time.Sleep(10 * time.Millisecond)428 diagI2cWrite1Byte(0x00, 0x26, 0x00)429 result, _ = diagI2cPing(0x00, 0x26, 0x00, 10)430 r = CheckPassB(result, true)431 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9534_main_gpio0", "-",432 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")433 diagI2cWrite1Byte(0x00, 0x71, 0x40)434 time.Sleep(10 * time.Millisecond)435 result, _ = diagI2cPing(0x00, 0x5e, 0x00, 10)436 r = CheckPassB(result, true)437 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_pex8780", "-",438 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")439 diagI2cWrite1Byte(0x00, 0x71, 0x00)440 time.Sleep(10 * time.Millisecond)441 // MAIN_MUX1442 //443 result, _ = diagI2cPing(0x00, 0x72, 0x00, 10)444 r = CheckPassB(result, true)445 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_main_mux1", "-",446 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")447 diagI2cWrite1Byte(0x00, 0x72, 0x01)448 time.Sleep(10 * time.Millisecond)449 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)450 r = CheckPassB(result, true)451 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio1", "-",452 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")453 diagI2cWrite1Byte(0x00, 0x72, 0x02)454 time.Sleep(10 * time.Millisecond)455 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)456 r = CheckPassB(result, true)457 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio2", "-",458 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")459 diagI2cWrite1Byte(0x00, 0x72, 0x04)460 time.Sleep(10 * time.Millisecond)461 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)462 r = CheckPassB(result, true)463 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio3", "-",464 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")465 diagI2cWrite1Byte(0x00, 0x72, 0x08)466 time.Sleep(10 * time.Millisecond)467 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)468 r = CheckPassB(result, true)469 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio4", "-",470 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")471 diagI2cWrite1Byte(0x00, 0x72, 0x10)472 time.Sleep(10 * time.Millisecond)473 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)474 r = CheckPassB(result, true)475 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio5", "-",476 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")477 diagI2cWrite1Byte(0x00, 0x72, 0x20)478 time.Sleep(10 * time.Millisecond)479 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)480 r = CheckPassB(result, true)481 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio6", "-",482 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")483 diagI2cWrite1Byte(0x00, 0x72, 0x40)484 time.Sleep(10 * time.Millisecond)485 result, _ = diagI2cPing(0x00, 0x76, 0x00, 10)486 r = CheckPassB(result, true)487 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9539_main_gpio7", "-",488 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")489 diagI2cWrite1Byte(0x00, 0x72, 0x80)490 time.Sleep(10 * time.Millisecond)491 diagI2cWrite1Byte(0x00, 0x75, 0x00)492 result, _ = diagI2cPing(0x00, 0x75, 0x00, 10)493 r = CheckPassB(result, true)494 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_9534_led_gpio0", "-",495 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")496 diagI2cWrite1Byte(0x00, 0x72, 0x00)497 time.Sleep(10 * time.Millisecond)498 // FRU_MUX0499 //500 result, _ = diagI2cPing(0x01, 0x70, 0x00, 10)501 r = CheckPassB(result, true)502 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux0", "-",503 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")504 diagI2cWrite1Byte(0x01, 0x70, 0x01)505 time.Sleep(10 * time.Millisecond)506 result, _ = diagI2cPing(0x01, 0x73, 0x00, 10)507 r = CheckPassB(result, true)508 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux1", "-",509 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")510 diagI2cWrite1Byte(0x01, 0x70, 0x02)511 time.Sleep(10 * time.Millisecond)512 result, _ = diagI2cPing(0x01, 0x73, 0x00, 10)513 r = CheckPassB(result, true)514 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux2", "-",515 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")516 diagI2cWrite1Byte(0x01, 0x70, 0x04)517 time.Sleep(10 * time.Millisecond)518 result, _ = diagI2cPing(0x01, 0x73, 0x00, 10)519 r = CheckPassB(result, true)520 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux3", "-",521 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")522 diagI2cWrite1Byte(0x01, 0x70, 0x08)523 time.Sleep(10 * time.Millisecond)524 result, _ = diagI2cPing(0x01, 0x73, 0x00, 10)525 r = CheckPassB(result, true)526 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux4", "-",527 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")528 diagI2cWrite1Byte(0x01, 0x70, 0x10)529 time.Sleep(10 * time.Millisecond)530 result, _ = diagI2cPing(0x01, 0x73, 0x00, 10)531 r = CheckPassB(result, true)532 fmt.Printf("%15s|%25s|%10s|%10t|%10t|%10t|%6s|%35s\n", "i2c", "ping_fru_mux5", "-",533 result, i2cping_response_min, i2cping_response_max, r, "ping device 10x")534 diagI2cWrite1Byte(0x01, 0x70, 0x00)535 //i2c START536 sd[0] = 0537 j[0] = I{true, i2c.Write, 0, 0, sd, int(0x99), int(0), 0}538 err = DoI2cRpc()539 if err != nil {540 log.Print(err)541 }542}543func diagI2cCh1Lc() {544}545func diagSwitchConsole() error {546 //i2c STOP547 sd[0] = 0...

Full Screen

Full Screen

pinpongprgms.go

Source:pinpongprgms.go Github

copy

Full Screen

...6 "fmt"7 "time"8)910// The pinger prints a ping and waits for a pong11func pinger(pinger <-chan int, ponger chan<- int) {12 for {13 <-pinger14 fmt.Println("ping")15 time.Sleep(time.Second)16 ponger <- 117 }18}1920// The ponger prints a pong and waits for a ping21func ponger(pinger chan<- int, ponger <-chan int) {22 for {23 <-ponger24 fmt.Println("pong")25 time.Sleep(time.Second)26 pinger <- 127 }28}2930func main() {31 ping := make(chan int)32 pong := make(chan int)3334 go pinger(ping, pong)35 go ponger(ping, pong)3637 // The main goroutine starts the ping/pong by sending into the ping channel38 ping <- 13940 for {41 // Block the main thread until an interrupt42 time.Sleep( 10 * time.Second)43 break44 }45}46output:47PS C:\Users\Sudha\Desktop\golang\sudha\assign\pingpong> go run ping4.go;48ping49pong50ping51pong52ping53pong54ping55pong56ping57pong5859program:6061package main62 63import (64 "fmt"65 "time"66)67 68func main() {69 pingChan := make(chan int, 1)70 pongChan := make(chan int, 1)71 72 go ping(pingChan, pongChan)73 go pong(pongChan, pingChan)74 75 pingChan <- 176 77 select {}78}79 80func ping(pingChan <-chan int, pongChan chan<- int) {81 for {82 ball := <-pingChan83 84 fmt.Println("Ping", ball)85 time.Sleep(1 * time.Second)86 87 pongChan <- ball+188 }89}90 91func pong(pongChan <-chan int, pingChan chan<- int) {92 for {93 ball := <-pongChan94 95 fmt.Println("Pong", ball)96 time.Sleep(1 * time.Second)97 98 pingChan <- ball+199100 for {101 // Block the main thread until an interrupt102 time.Sleep(time.Second)103 }104 }105}106107 108output:109PS C:\Users\Sudha\Desktop\golang\sudha\assign\pingpong> go run ping3.go;110Ping 1111Pong 2112Ping 3113Pong 4114Ping 5115Pong 6116Ping 7117Pong 8118Ping 9119Pong 10120121program:122123package main124125import (126 "fmt"127 "time"128)129130func main() {131 ping := make(chan struct{}, 1)132 pong := make(chan struct{}, 1)133134 ping<- struct{}{}135136 go play(ping, pong)137138 time.Sleep(time.Millisecond)139}140141func play(ping, pong chan struct{}) {142 for {143 select {144 case <-ping:145 fmt.Println("ping")146 pong<- struct{}{}147 case <-pong:148 fmt.Println(" pong")149 ping<- struct{}{}150 }151 }152}153154output:155156PS C:\Users\Sudha\Desktop\golang\sudha\assign\pingpong> go run ping2.go;157ping158pong159ping160 pong161ping162 pong163ping164 pong165ping166 pong167ping168 pong169ping170 pong171ping172173174program:175176package main177178179import "fmt"180181182func main() {183 184pingChan := make(chan string)185 186pongChan := make(chan string)187188 189go printer(pongChan)190 191go pinger(pingChan)192 193go ponger(pingChan, pongChan)194195 196197198var input string199 200fmt.Scanln(&input)201202}203204205206func pinger(pingChan chan<- string) {207208 209fmt.Println("pinger sending \"ping\"")210 pingChan <- "ping"211212}213214215216func ponger(pingChan <-chan string, pongChan chan<- string) {217 218fmt.Println("ponger received", <-pingChan)219220 // respond with a pong221 222223fmt.Println("ponger replying with \"pong\"")224 pongChan <- "pong"225226}227228229230func printer(pongChan <-chan string) {231232fmt.Println("printer received", <-pongChan)233234}235output:236PS C:\Users\Sudha\Desktop\golang\sudha\assign\pingpong> go run ping.go;237pinger sending "ping"238ponger received ping239ponger replying with "pong"240printer received pong241f ...

Full Screen

Full Screen

GoRoutineMecanisme.go

Source:GoRoutineMecanisme.go Github

copy

Full Screen

...3 "fmt"4 "time"5)6// Ecrie dans mon channel : (c : channel)7func ping(c chan string) {8 // on increment de 1 en 1 a chaque tour de boucle9 for i := 1; ; i++ {10 c <- fmt.Sprintf("ping %v", i)11 }12}13// Ecrire dans mon channel14func pong(c chan string) {15 // on increment de 100 a 100 a chaque tour de boucle16 for i := 100; ; i += 100 {17 c <- fmt.Sprintf("pong %v", i)18 }19}20// Lire mon channel21func print(c chan string) {22 // as While() {}23 // on lit a l'interieur de mon channel et on stock dans msg24 // Boucle infini25 for {26 msg := <-c27 fmt.Println(msg)28 // On attend une seconde entre chaque lecture29 time.Sleep(1 * time.Second)30 }31}32// GOROUTINES & CHANNELS33// Entry point of application34// $ go run main.go35func main() {36 // On declare un channel37 c := make(chan string) // est une goroutine38 // Lancer une go routine a plusieurs fonctions a la fois39 go ping(c)40 go pong(c)41 go print(c)42 // fin d'execution apres 10 seconds43 time.Sleep(10 * time.Second)44}45/*46GO ROUTINE MULTI EXECUTION47~/go/src/training.go/goroutines$ go run main.go48ping 149pong 10050ping 251pong 20052ping 353pong 30054ping 455pong 40056ping 557pong 50058*/59/*60// $ go run main.go61func main() {62 // On declare un channel63 c := make(chan string) // est une goroutine64 // Lancer une go routine a une fonction65 go ping(c)66 go print(c)67 // fin d'execution apres 10 seconds68 time.Sleep(10 * time.Second)69}70~/go/src/training.go/goroutines$ go run main.go71ping 172ping 273ping 374ping 475ping 576ping 677ping 778ping 879ping 980ping 1081*/...

Full Screen

Full Screen

ping

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, World!")4 ping()5}6import "fmt"7func ping() {8 fmt.Println("ping")9}

Full Screen

Full Screen

ping

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Ping from main")4}5import (6func main() {7 fmt.Println("Ping from main")8}9import (10func main() {11 fmt.Println("Ping from main")12}13import (14func main() {15 fmt.Println("Ping from main")16}17import (18func main() {19 fmt.Println("Ping from main")20}21import (22func main() {23 fmt.Println("Ping from main")24}25import (26func main() {27 fmt.Println("Ping from main")28}29import (30func main() {31 fmt.Println("Ping from main")32}33import (34func main() {35 fmt.Println("Ping from main")36}37import (38func main() {39 fmt.Println("Ping from main")40}41import (42func main() {43 fmt.Println("Ping from main")44}45import (46func main() {47 fmt.Println("Ping from main")48}49import (50func main() {51 fmt.Println("

Full Screen

Full Screen

ping

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, playground")4 main.Ping()5}6import "fmt"7func main() {8 fmt.Println("Hello, playground")9 main.Pong()10}11import "fmt"12func main() {13 fmt.Println("Hello, playground")14 main.Ping()15}16import "fmt"17func main() {18 fmt.Println("Hello, playground")19 main.Pong()20}21import "fmt"22func main() {23 fmt.Println("Hello, playground")24 main.Ping()25}26import "fmt"27func main() {28 fmt.Println("Hello, playground")29 main.Pong()30}31import "fmt"32func main() {33 fmt.Println("Hello, playground")34 main.Ping()35}36import "fmt"37func main() {38 fmt.Println("Hello, playground")39 main.Pong()40}41import "fmt"42func main() {43 fmt.Println("Hello, playground")44 main.Ping()45}46import "fmt"47func main() {48 fmt.Println("Hello, playground")49 main.Pong()50}51import "fmt"52func main() {53 fmt.Println("Hello, playground")54 main.Ping()55}56import "fmt"57func main() {58 fmt.Println("Hello, playground")59 main.Pong()60}61import "fmt"62func main() {63 fmt.Println("Hello, playground")

Full Screen

Full Screen

ping

Using AI Code Generation

copy

Full Screen

1func main() {2 fmt.Println("Hello, playground")3 Ping()4}5import "fmt"6func Ping() {7 fmt.Println("Ping")8}9import "pkg/main.go"10package pkg (test)11 imports pkg12 imports pkg: import cycle not allowed13import "pkg/main.go"14package pkg (test)15 imports pkg16 imports pkg: import cycle not allowed17I am trying to import a file from another package. I have the following structure:18import (19func main() {20 fmt.Println("Hello, playground")21 pkg.Ping()22}23I have a file named pkg.go in the pkg folder. I want to import pkg.go into main.go24import "github.com/username/project/pkg/pkg.go"25 imports github.com/username/project/pkg/pkg.go: cannot import absolute path26import "pkg/main.go"27package pkg (test)28 imports pkg29 imports pkg: import cycle not allowed30import "pkg/main.go"31package pkg (test)32 imports pkg33 imports pkg: import cycle not allowed

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selenoid automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful