Save
Saving
  • guluting

    固件下载地址:
    https://support.hpe.com/hpsc/swd/public/detail?swItemId=MTX_3830eb5b87574d6cb463c44994

    如果地址不可用的话可自己搜索下:
    1、进入搜索页面
    https://support.hpe.com/hpesc/public/km/search
    2、搜索关键词:
    “HPE ProLiant MicroServer Gen8 Server”
    3、内容区上方选择:
    “DRIVERS AND SOFTWARE”
    4、左边栏筛选:

    • Firmware
    • Lights-Out Management

    然后我选择了:
    “* RECOMMENDED * REMOVED Online ROM Flash Component for Linux - HPE Integrated Lights-Out 4”
    点击后进入介绍页面,在介绍页面点击“Obtain software”按钮进入下载页面。

    在下载页面有exe和rpm两个版本,随便选择一个版本下载后进行解压,在里边找到“ilo4_xxx.bin”文件,这个就是ILO的固件升级程序。

    posted in GuaiK机房 read more
  • guluting

    错误信息:

    yum update
    Loaded plugins: fastestmirror
    base                                                                                                                                                  | 3.6 kB  00:00:00
    
    
     One of the configured repositories failed (Unknown),
     and yum doesn't have enough cached data to continue. At this point the only
     safe thing yum can do is fail. There are a few ways to work "fix" this:
    
         1. Contact the upstream for the repository and get them to fix the problem.
    
         2. Reconfigure the baseurl/etc. for the repository, to point to a working
            upstream. This is most often useful if you are using a newer
            distribution release than is supported by the repository (and the
            packages for the previous distribution release still work).
    
         3. Run the command with the repository temporarily disabled
                yum --disablerepo=<repoid> ...
    
         4. Disable the repository permanently, so yum won't use it by default. Yum
            will then just ignore the repository until you permanently enable it
            again or use --enablerepo for temporary usage:
    
                yum-config-manager --disable <repoid>
            or
                subscription-manager repos --disable=<repoid>
    
         5. Configure the failing repository to be skipped, if it is unavailable.
            Note that yum will try to contact the repo. when it runs most commands,
            so will have to try and fail each time (and thus. yum will be be much
            slower). If it is a very temporary problem though, this is often a nice
            compromise:
    
                yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
    
    Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
    

    解决方案

    # 1、删除epel.repo
    rm -rf /etc/yum.repos.d/epel.repo
    rm -rf /etc/yum.repos.d/epel-testing.repo
    
    # 2、检查DNS
    vi /etc/resolv.conf
    # 添加: nameserver 8.8.8.8
    # 重启网络服务
    systemctl restart network
    
    # 测试是否修复
    yum update
    

    posted in GuaiK机房 read more
  • guluting

    hostnamectl set-hostname guaik.org
    
    vi /etc/hosts
    # 在127.0.0.1后面加上[hostname]
    # 如果有外网IP的话也需要修改
    127.0.0.1      localhost.localdomain localhost
    xx.xx.xx.xx    guaik.org # 外网IP
    
    # 检查修改
    hostname -f
    cat /etc/hosts
    

    posted in GuaiK机房 read more
  • guluting

    我通常使用VSCode+CMake开发C++的程序,但是即使我在CMakeLists.txt中配置了Include的路径VSCode在#include时不但不自动补全路径还显示红色的波浪下划线。为了让VSCode能够知道Include的路径还需要针对当前工程配置.vscode/c_cpp_properties.json文件,可以通过shift+command+P然后选择C/C++: Edit Configurations(JSON)生成该文件。
    然后配置c_cpp_properties.json中的includePath字段:

    {
        "configurations": [
            {
                "name": "Mac",
                "includePath": [
                    "${workspaceFolder}/**",
                    "${workspaceFolder}/glm",
                    "${workspaceFolder}/glad",
                ],
                "defines": [],
                "macFrameworkPath": [],
                "compilerPath": "/usr/local/bin/gcc-8",
                "cStandard": "c11",
                "cppStandard": "c++17",
                "intelliSenseMode": "clang-x64"
            }
        ],
        "version": 4
    }
    

    配置后导入头文件:(例如demo.cpp在根目录下)

    // This is demo.cpp
    #include "glad/include/glad.h"
    #include "glm/glm.hpp"
    

    这时候就能够智能补全,红色波浪下划线也消失了。

    posted in GuaiK实验室 read more
  • guluting

    main.cpp

    #include <QApplication>
    #include <QDebug>
    #include "canvas.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QSurfaceFormat glFormat;
        glFormat.setVersion(3, 3);                           //  设置OpenGL版本
        glFormat.setProfile(QSurfaceFormat::CoreProfile);    // 设置使用核心模式
        QSurfaceFormat::setDefaultFormat(glFormat);
    
        Canvas *c = new Canvas();
        c->show();
    
        return a.exec();
    }
    

    Canvas.h

    #ifndef CANVAS_H
    #define CANVAS_H
    
    #include <QWidget>
    #include <QOpenGLWidget>
    #include <QOpenGLExtraFunctions>
    
    class Canvas : public QOpenGLWidget,protected QOpenGLExtraFunctions
    {
        Q_OBJECT
    public:
        explicit Canvas();
    
    signals:
    
    public slots:
    
    private:
    
    protected:
        virtual void initializeGL();
        virtual void resizeGL(int w, int h);
        virtual void paintGL();
    
    private:
        GLuint shaderProgram;
    };
    
    #endif
    

    Canvas.cpp

    #include "canvas.h"
    #include <QtDebug>
    #include <QtOpenGL>
    
    // 以下为测试代码,不推荐这么写
    // =================================
    GLuint VBO, VAO;
    const char *vertexShaderSource =
            "#version 330 core\n"
            "layout(location = 0) in vec3 aPos;\n"
            "void main(){\n"
            "  gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
            "}\n\0";
    const char *fragmentShaderSource =
            "#version 330 core\n"
            "out vec4 FragColor;\n"
            "void main(){\n"
            "   FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
            "}\n\0";
    // =================================
    
    Canvas::Canvas()
    {
    
    }
    
    void Canvas::initializeGL()
    {
        //着色器部分
        this->initializeOpenGLFunctions();
        int vertexShader = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
        glCompileShader(vertexShader);
    
        int success;
        char infoLog[512];
        glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
        if (!success)
        {
            glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
            qDebug() << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << endl;
        }
    
        int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
    
        glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
        glCompileShader(fragmentShader);
    
        glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
        if (!success)
        {
            glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
            qDebug() << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << endl;
        }
        shaderProgram = glCreateProgram();
        glAttachShader(shaderProgram, vertexShader);
        glAttachShader(shaderProgram, fragmentShader);
        glLinkProgram(shaderProgram);
    
        glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
        if (!success) {
            glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
            qDebug() << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << endl;
        }
        glDeleteShader(vertexShader);
        glDeleteShader(fragmentShader);
    
        GLfloat vertices[] = {
            -0.5f, -0.5f, 0.0f,
            0.5f, -0.5f, 0.0f,
            0.0f,  0.5f, 0.0f
        };
    
        glGenVertexArrays(1, &VAO);
        glGenBuffers(1, &VBO);
        glBindVertexArray(VAO);
        glBindBuffer(GL_ARRAY_BUFFER, VBO);
    
        glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (void*)0);
        glEnableVertexAttribArray(0);
    
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindVertexArray(0);
    }
    
    void Canvas::resizeGL(int width, int height)
    {
        glViewport(0, 0, width, height);
    }
    
    void Canvas::paintGL()
    {
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);
    
        glUseProgram(shaderProgram);
        glBindVertexArray(VAO);
        glDrawArrays(GL_TRIANGLES, 0, 3);
        glUseProgram(0);
    }
    

    posted in GuaiK实验室 read more
  • guluting

    使用PlatformIO开发:

    1、Libraries中搜索LiquidCrystal,然后选择”By Arduino“的安装。
    2、修改platformio.ini文件(在lib_deps中添加库)

    [env:uno]
    platform = atmelavr
    board = uno
    framework = arduino
    lib_deps = 
        LiquidCrystal
    

    将Arduino与LCD的线接起来[ GND,VCC(5v),SDA,SCL ]

    0_1560937221828_WechatIMG146.jpeg

    • PS:上图中LCD背面有个蓝色的旋钮,是用来调整对比度的,如果LCD无法显示文字的话可以尝试调节该旋钮。

    DEMO

    #include <Arduino.h>
    #include <LiquidCrystal_I2C.h>
    
    LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
    
    void setup() {
    // 初始化LCD,每行16个字符,共两行
    lcd.begin(16, 2);
     
    // 背光闪烁三次
    for(int i = 0; i < 3; i++) {
    lcd.backlight(); 
    delay(250);
    lcd.noBacklight();
    delay(250);
    }
    lcd.backlight();
     
    lcd.setCursor(0, 0); // 设置游标:第一行第一列
    lcd.print(" Welcome Guaik ");
    delay(1000);
    lcd.setCursor(0, 1); // 设置游标:第二行第一列
    lcd.print("<bbs.guaik.org>");
    delay(3000);
    lcd.clear(); // 清除内容
    }
    void loop() {
    lcd.setCursor(0, 0); 
    lcd.print("Message:");
    lcd.setCursor(0, 1);
    lcd.print("Hello world");
    }
    

    如果无法正常工作的话,请检查I2C的设备地址,也就是LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);的第一个参数,当前的是0x3F。


    0_1560937679044_2019-06-19 171658.gif

    posted in GuaiK实验室 read more
  • guluting

    Upload错误:dyld: Library not loaded: /usr/local/opt/libftdi/lib/libftdi1.2.dylib

    解决方式:brew reinstall openocd


    设置默认项目路径:

    cd /Users/[UserName]/.platformio
    vi homestate.json
    

    找到:"projectsDir"把后面的路径设置成你的工程目录

    posted in GuaiK实验室 read more
  • guluting

    拷屁一段protobuf的简介:

    Protocol buffers是一个灵活的、高效的、自动化的用于对结构化数据进行序列化的协议,与XML相比,Protocol buffers序列化后的码流更小、速度更快、操作更简单。你只需要将要被序列化的数据结构定义一次(译注:使用.proto文件定义),便可以使用特别生成的源代码(译注:使用protobuf提供的生成工具)轻松的使用不同的数据流完成对这些结构数据的读写操作,即使你使用不同的语言(译注:protobuf的跨语言支持特性)。你甚至可以更新你的数据结构的定义(译注:就是更新.proto文件内容)而不会破坏依赖“老”格式编译出来的程序。

    示例.proto文件(api.proto):

    syntax = "proto3";
    
    package gkeng.comet;
    
    option go_package = "grpc";
    
    import "github.com/gogo/protobuf/gogoproto/gogo.proto";
    
    // protocol
    message Proto {
      int32 ver = 1 [(gogoproto.jsontag) = "ver"];
      int32 op = 2 [(gogoproto.jsontag) = "op"];
      int32 seq = 3 [(gogoproto.jsontag) = "seq"];
      int32 body = 4 [(gogoproto.jsontag) = "body"];
    }
    

    生成指令(.pb.go文件)

    protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf --go_out=plugins=grpc:. ./api.proto

    • 通过-I引入了当前目录、Golang的源码目录和github.com/gogo/protobuf

    • 列表--go_out=plugins=grpc:.:在执行时添加grpc的plugin

    • 列表指定的./api.proto就是我们编写的数据结构文件


    .proto 描述文件的编写说明这里就不写了

    posted in GuaiK实验室 read more
  • guluting

    Reader分析


    数据结构

    type Reader struct {
        rd   io.Reader     // 被读取的io缓存,可以是网络的或文件的
        buf  []byte        // 缓冲区,用于给rd当缓存使用
        r, w int           // 读写游标,用来管理buf字段的
        err  error         // 存储当前Reader的异常值
    }
    

    常量分析

    const defaultBufSize = 4096   // 针对Reader中的buf字段,默认缓冲区大小(byte)
    const minReadBufferSize = 16  // 在初始化Reader结构的时候,能够设置的最小的缓冲区大小
    const maxConsecutiveEmptyReads = 100  // 从rd中读取数据无数据(fill操作)返回时(n==0)时,最多的读取次数
    

    函数分析
    func (b *Reader) fill();

    1、缓存对齐,如果读游标不在缓存的起始位置,则将可读数据对齐到起始位置copy(buf,buf[r:w])
    2、经过对齐后,如果w的游标超出了缓冲区的长度,则抛出一次异常
    3、尝试maxConsecutiveEmptyReads次从rd中读取数据到buf中,直到出现异常或者成功的读到数据到buf中了返回,如果超出了尝试次数则设置err为io.ErrNoProgress


    白色:空闲内存,可写入数据
    绿色:已写入内存,可读取数据
    灰色:已读取内存,可回收(fill函数在填充数据的同时会处理回收)
    0_1558596290334_未命名.png

    图中初始时有10个空闲块,R和W都指向下标0处。
    向内存中写入了5Byte的数据,这时候R在下标0处,W指向了下标5,这时候的可读数据为W-R=5Byte。
    读取了3Byte的数据,这时候R指向下标3,可读数据为W-R = 2,可回收空间为R。
    回收已读数据copy(buf,buf[r:w]),将R到W区间的数据平移至buf下标为0的位置。

    posted in GuaiK实验室 read more
  • guluting

    看了Go语言的书后发现它有切片和map类型,但是没有Set类型,那么这时候如果需要用到Set类型如何实现呢?
    借助map和struct就可以很轻易的实现,利用两个特点:
    1、map的key是不会重复的
    2、struct{}是占用0内存空间的


    // 先定义map类型,key为int32,value为struct{}
    var mySet map[int32]struct{}
    // 使用make为map分配内存并初始化
    mySet = make(map[int32]struct{})
    // 使用mySet
    mySet[0] = struct{}{}
    mySet[100] = struct{}{} 
    

    struct{}{}的定义

     struct{}  {}
    |  ^     | ^
      type     empty element list
    

    posted in GuaiK实验室 read more