长城电源FRU分析

一.实际数据区

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 01 01 00 00 03 0b 00 f0 01 23 00 00 00 64 02 00    ??..??.??#...d?.
10: 00 00 00 00 00 00 12 02 01 08 00 ca 47 52 45 41    ......????.?GREA
20: 54 20 57 41 4c 4c cc 43 52 50 53 31 33 30 30 44    T WALL?CRPS1300D
30: 32 20 20 cc 43 52 50 53 31 33 30 30 44 32 20 20    2  ?CRPS1300D2  
40: c3 30 31 20 cf 32 4f 30 35 34 30 34 35 38 32 32    ?01 ?2O054045822
50: 20 20 20 20 c0 c0 c1 4b 00 02 18 5a 8c 14 05 ff        ???K.??Z???.
60: ff ff 00 28 23 90 33 50 46 20 67 00 3f 0a 0e ff    ...(#?3PF g.???.
70: 0f 00 00 00 00 09 02 0d d5 13 01 c4 04 88 04 00    ?....??????????.
80: 05 78 00 64 00 cc 29 01 82 0d 86 ea 82 c4 04 88    ?x.d.?)?????????
90: 04 00 05 78 00 64 00 b8 0b 00 00 00 00 00 00 00    ?.?x.d.??.......
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
f0: 70 53 e8 03 cf 0a 00 00 00 00 00 00 00 00 00 00    pS????..........

二.COMMON HEADER
0    Common Header Format Version            01
1    Internal Use Area Starting Offset             01   1*8 =8  0x08  确定偏移位置
2    Chassis Info Area Starting Offset             00
3    Board Area Starting Offset                       00
4    Product Info Area Starting Offset             03   3*8 =24 0x18
5    MultiRecord Area Starting Offset             0b   11*8=88 0x58
6    PAD, write as 00h                                    00
7    Common Header Checksum                    f0

三.Internal Use Area Format
8    Internal Use Format Version                    01
9-17 Internal use data                                   23 00 00 00 64 02 00 00 00 00 00 00 00 12 02
    (没固定要求)

四.Product Info Area Format
18   Product Area Format Version                 01
19   Product Area Length                              08
1a   Language Code                                     00   en
1b  Manufacturer Name type/length byte     ca  
    0xca   0011 1010           type  [7-6] = 00 binary or unspecified
                                         length [5-0] = 111010=0x3a=58  (0x1b+0x3a=0x55)
1c-55 Manufacturer Name bytes        
56                                                                  C1h (表示后面已经没有了).
57  Product Info Area Checksum                   4b .


五.MultiRecord Area Record Header
58    Record Type ID                                      00---Power Supply Information
59                                                                   02
    [7:7] – End of list                                                       0
    [6:4] – Reserved, write as 000b                            000
    [3:0] – Record Format version                              010
5a    Record Length                                       18    0x18=24  0x5c+0x18=0x74
5b    Record Checksum                                 5a
5c    Header Checksum                                 8c

五.1:Power Supply Information
off   val         name 
0    1405
2    ffff          Peak VA
4        ff        Inrush current            
5       00       Inrush interval in ms.
6      2328    Low end Input voltage range 1   0x2328=9000=90.00v
8      3390    High end Input voltage range 1  0x3390=13200=132.00v
10     4650   Low end Input voltage range 2   0x4650=18000=180.00v
12      6720  High end Input voltage range 2  0x6720=26400=264.00v
14        00    Low end Input frequency range            00hz
15        3f     High end Input frequency range            63hz
16        0a    Input dropout tolerance in ms          10ms
17        0e    Binary flags:
18      0fff     Peak Wattage.
20  000000  Combined Wattage
23        00    Predictive fail tachometer lower threshold 


五.2:MultiRecord Area Record Header
75    Record Type ID                                09---Extended DC Output
76                                                             02
    [7:7] – End of list                                   0
    [6:4] – Reserved, write as 000b            000
    [3:0] – Record Format version              010
77    Record Length                                  0d    0xd=13  0x79+0xd=0x86
78    Record Checksum                            d5
79    Header Checksum                           13


      Extended DC Output (Record Type 0x09)
off   val    name 
0       01
1      04c4
3     0488
5     0500
7     0078
9     0064
11    29cc

        具体解释同下

五.3:MultiRecord Area Record Header
87    Record Type ID                                 01---DC Output
88                                                              82
    [7:7] – End of list                                     1
    [6:4] – Reserved, write as 000b           000
    [3:0] – Record Format version              010
89    Record Length                                     0d    0xd=13  0x8b+0xd=0x98
8a    Record Checksum                               86
8b    Header Checksum                               ea

    DC Output (Record Type 0x01)
off   val    name 
0      82    Output information
1     04c4    Nominal voltage (10 mV)                                 0x4c4=1220=12.20v
3     0488  Maximum negative voltage (10 mV)                   0x488=1160=11.60v
5     0500  Maximum positive voltage (10 mV)                     0x500=1280=12.80v
7     0078  Ripple and Noise pk-pk 10Hz to 30 MHz (mV)    0x78=120=1.2v
9     0064  Minimum current draw (mA)                                0x64=100ma
11    0bb8    Maximum current draw (mA)                            0xbb8=3000ma

添加一个获取PSU信息的demo

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <string.h>

#define I2C_BUS_TEMPLATE "/dev/i2c-%d"
#define MAX_BUS 9
#define MAX_ADDR 0xFF


 
void print_usage(const char *prog_name) {
    fprintf(stderr, "Usage: %s <bus> <add>\n", prog_name);
    fprintf(stderr, "  <bus>: I2C bus number (0-9)\n");
    fprintf(stderr, "  <add>: I2C address (0x00-0xFF)\n");
}
 
// 函数定义:以十六进制格式打印数组
void print_hex_array(const uint8_t *buffer, size_t length) {
    for (size_t i = 0; i < length; i++) {
        printf("%02X ", buffer[i]);
        if ((i + 1) % 16 == 0) { // 每行打印16个字节
            printf("\n");
        }
    }
    printf("\n"); // 在最后一行之后打印一个换行符
}
 
int main(int argc, char *argv[]) {
	
    if (argc != 3) {
        print_usage(argv[0]);
        return EXIT_FAILURE;
    }
 
    int bus_num = atoi(argv[1]);
    if (bus_num < 0 || bus_num > MAX_BUS) {
        fprintf(stderr, "Invalid bus number: %d\n", bus_num);
        print_usage(argv[0]);
        return EXIT_FAILURE;
    }
 
    unsigned int addr = strtoul(argv[2], NULL, 16);
    if (addr < 0x00 || addr > 0xff) {
        fprintf(stderr, "Invalid address: 0x%X\n", addr);
        print_usage(argv[0]);
        return EXIT_FAILURE;
    }
 
    char bus_path[32];
    snprintf(bus_path, sizeof(bus_path), I2C_BUS_TEMPLATE, bus_num);
 
    int file = open(bus_path, O_RDWR);
    if (file < 0) {
        perror("Failed to open the i2c bus");
        return EXIT_FAILURE;
    }
 
    if (ioctl(file, I2C_SLAVE, addr) < 0) {
        perror("Failed to acquire bus access and/or talk to slave");
        close(file);
        return EXIT_FAILURE;
    }
 
	uint8_t full_buffer[256];
 

    if (read(file, full_buffer, 256) != 256) {
        perror("Failed to read from the i2c bus");
        close(file);
        return EXIT_FAILURE;
    }
 
	//print_hex_array(full_buffer, 256);
    printf("PSU_info:%.23s\n", full_buffer + 0x1c);
    close(file);
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值