Please help, converted into Delphi language code,
# # ifndef THINKGEAR_STREAM_PARSER_H_
# define THINKGEAR_STREAM_PARSER_H_
# define PARSER_TYPE_NULL 0 x00
# define PARSER_TYPE_PACKETS 0 x01
# define PARSER_TYPE_2BYTERAW 0 x02
# define PARSER_CODE_BATTERY 0 x01
# define PARSER_CODE_POOR_QUALITY 0 x02
# define PARSER_CODE_ATTENTION 0 x04
# define PARSER_CODE_MEDITATION 0 x05
# define PARSER_CODE_8BITRAW_SIGNAL 0 x06
# define PARSER_CODE_RAW_MARKER 0 x07
# define PARSER_CODE_RAW_SIGNAL 0 x80
# define PARSER_CODE_EEG_POWERS 0 x81
# define PARSER_CODE_ASIC_EEG_POWER_INT 0 x83
Typedef struct _ThinkGearStreamParser {
Unsigned char type;
Unsigned char state;
Unsigned char lastByte;
Unsigned char payloadLength;
Unsigned char payloadBytesReceived;
Unsigned char content [256].
Unsigned char payloadSum;
Unsigned char chksum.
Void (* handleDataValue) (unsigned char extendedCodeLevel,
Unsigned char code, unsigned char numBytes,
Const unsigned char * value, void * customData);
Void * customData;
} ThinkGearStreamParser;
Int
THINKGEAR_initParser (ThinkGearStreamParser * parser, unsigned char parserType,
Void (* handleDataValueFunc) (
Unsigned char extendedCodeLevel,
Unsigned char code, unsigned char numBytes,
Const unsigned char * value, void * customData),
Void * customData);
Void
ExampleHandleDataValueFunc (unsigned char extendedCodeLevel,
Unsigned char code,
Unsigned char numBytes,
Const unsigned char * value,
Void * customData);
Int
THINKGEAR_parseByte (ThinkGearStreamParser * parser, unsigned char byte);
CodePudding user response:
{$# ifndef THINKGEAR_STREAM_PARSER_H_}
{$define THINKGEAR_STREAM_PARSER_H_}
{$endif}
Const
PARSER_TYPE_NULL=$00;
PARSER_TYPE_PACKETS=$01;
PARSER_TYPE_2BYTERAW=$02;
PARSER_CODE_BATTERY=$01;
PARSER_CODE_POOR_QUALITY=$02;
PARSER_CODE_ATTENTION=$4.
PARSER_CODE_MEDITATION=$5;
PARSER_CODE_8BITRAW_SIGNAL=$6;
PARSER_CODE_RAW_MARKER=$7;
PARSER_CODE_RAW_SIGNAL=$80;
PARSER_CODE_EEG_POWERS=$81;
PARSER_CODE_ASIC_EEG_POWER_INT=$83;
Type
ThandleDataValue=https://bbs.csdn.net/topics/procedure (extendedCodeLevel, code, numBytes: char;
Const value: PChar; CustomData: Pointer);
PThandleDataValue=https://bbs.csdn.net/topics/^ ThandleDataValue;
_ThinkGearStreamParser=record
_type: char;
State: char;
LastByte: char;
PayloadLength: char;
PayloadBytesReceived: char;
Content: an array of char [0.. 255];
PayloadSum: char;
Chksum: char;
HandleDataValue: PThandleDataValue;
CustomData: Pointer;
end;
ThinkGearStreamParser=_ThinkGearStreamParser;
PThinkGearStreamParser=^ ThinkGearStreamParser;
The function THINKGEAR_initParser (parser: PThinkGearStreamParser;
ParserType: char;
HandleDataValueFunc: PThandleDataValue;
CustomData: Pointer) : integer;
Procedure exampleHandleDataValueFunc (extendedCodeLevel, code, numBytes: char;
Const value: PChar; CustomData: Pointer);
The function THINKGEAR_parseByte (parser: PThinkGearStreamParser; _byte: char) : integer;
CodePudding user response:
According to it,,CodePudding user response:
Thank you, I'm a little don't know C, thank you again,CodePudding user response:

