PROGRAMMING


  Python and PLC Communication

This article provides detailed steps on how to use Python to communicate with Schneider M221 and Siemens S7-1200 PLCs via Ethernet. Additionally, we offer a packaged Python PLC client library, enabling you to easily build your own SCADA control programs, such as Human-Machine Interfaces (HMI). The system overview is shown below:To check the project detail please refer to Python Physical PLC Communication Clients# Created: 2024/06/29# Version: v0.1.3# Copyright: Copyright (c) 2024 LiuYuancheng# License: MIT License IntroductionThis article will introduce beginner OT engineers...

25 0   


  Reflection in Java

What is Reflection?Reflection is a feature in Java that allows a program to obtain information about itself at runtime and dynamically manipulate the properties, methods, and constructors of classes or objects. With reflection, we can instantiate objects, call methods, and set properties without knowing the exact class name beforehand.The core of the reflection mechanism is the Class object, which represents a class. The Java Virtual Machine (JVM) automatically creates this Class object when it loads a class.How the JVM Creates a Class?When we write a class and compile it, the compiler convert...

536 0       METHOD FIELD TUTORIAL JAVA REFLECTION


  The Future of AI Chips Might Not Be GPU

In the layout of AI computing architectures, the model of CPUs working in collaboration with accelerator chips has become a typical AI deployment solution. CPUs act as providers of basic computing power, while accelerator chips are responsible for enhancing computational performance, aiding in the efficient execution of algorithms. Common AI accelerator chips can be categorized into three main types based on their technological paths: GPU, FPGA, and ASIC.In this competition, GPUs have emerged as the mainstream AI chip due to their unique advantages. So, how did GPUs stand out among many option...

573 0       CUDA ARM MICROSOFT NVIDIA GPU OPENAI INTEL


  GoLang Interview Questions

Below lists some frequently asked GoLang interview questions and their corresponding answers based on the author's experience. The list is updated frequently with new understandings. Stay tuned.What is the GMP model of GoLang?GoLang uses goroutine to achieve concurrency and it is famous for high concurrency support as the language defines its own goroutine dispatching and processing system which is well known as GMP model.How it works is that M is normally defined as the OS thread being spawned( then each M thread should be associated with a Process queue and each Process queue can have multip...

245 0       MEMORY CONCURRENCY INTERVIEW QUESTION GOLANG


  Performance comparison of string concatenation in Go language

In Go language, string concatenation is an inevitable operation during development, and efficient string concatenation is crucial for improving application performance. This article will delve into several common ways of string concatenation, provide performance comparisons, and offer optimization suggestions aimed at helping developers write more efficient code.Common ways of string concatenationIn Go language, common ways of string concatenation include the following:Using the + operator for concatenationIt's simple and straightforward, but each concatenation generates a new string, resultin...

1,410 0       STRING CONCATENATION PERFORMANCE COMPARISON


  Why init() is not recommended in Go

golangci lintCurrently, the unified CI's .golangci.yml includes the gochecknoinits checker:# golangci-lint v1.46.2# https://golangci-lint.run/usage/linterslinters: disable-all: true enable: ... - gochecknoinits # Checks that no init functions are present in Go code. ref: https://github.com/leighmcculloch/gochecknoinits ...If Go code uses the init() function, the following error will occur:# golangci-lint runfoo/foo.go:3:1: don't use `init` function (gochecknoinits)func init() {^That is, it's not recommended to use init().Why not to use init()Searching "golang why not use init" on G...

1,890 0       GOLANG INIT() SYNC.ONCE PANIC


  What is the use of empty struct in GoLang

In Go, an empty struct struct{} is a struct with no fields that may appear to be of little use, but in reality, it can be useful in certain situations and become a simple and efficient solution in code.As a semaphore or lockBecause the empty struct has no fields, it can be conveniently used to implement some concurrency control functions, such as mutex locks, read-write locks. We can use chan struct{} to implement an unbuffered channel for controlling concurrent access.package mainimport ( "fmt" "sync")func main() { var wg sync.WaitGroup var mu sync.Mutex c := make(chan struct{}...

7,126 2       EMPTY STRUCT GOLANG


  A journey to investigate a goroutine leakage case

In Go, creating goroutines is straightforward, but improper usage may result in a large number of goroutines unable to terminate, leading to resource leakage and memory leaks over time. The key to avoiding goroutine leaks is to manage the lifecycle of goroutines properly. By exporting runtime metrics and utilizing pprof, one can detect and resolve goroutine leakage issues.This post will go through one real case encountered by the author. The author maintains a service that connects to a target machine via SSH and executes commands. This is an internal service that is usually not closely monito...

1,037 0       LEAK DEBUG SSH TIMEOUT GUIDE GOLANG GOROUTINE PPROF