Related
I'm trying to implement a laptop keyboard on a microcontroller. I can not find usb codes for some fn buttons. The usb protocol has descriptions for combinations of changing the display brightness, volume, media keys, but more is needed. Can someone tell me where to find usb codes for disable touchpad or enable airplane mode?
Here is my descriptor now.
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x01, // Report ID (1)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x05, // REPORT_COUNT (5)
0x75, 0x01, // REPORT_SIZE (1)
0x05, 0x08, // USAGE_PAGE (LEDs)
0x19, 0x01, // USAGE_MINIMUM (Num Lock)
0x29, 0x05, // USAGE_MAXIMUM (Kana)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x03, // REPORT_SIZE (3)
0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0, // END_COLLECTION 65
0x05, 0x0C, // Usage Page (Consumer)
0x09, 0x01, // Usage (Consumer Control)
0xA1, 0x01, // Collection (Application)
0x85, 0x02, // Report ID (2)
0x05, 0x0C, // Usage Page (Consumer)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x08, // Report Count (8)
0x09, 0x6F, // Brightness Increment
0x09, 0x70, // Brightness Decrement
0x09, 0xB8, // Usage (Eject)
0x09, 0xCD, // Usage (Play/Pause)
0x09, 0xE2, // Usage (Mute)
0x09, 0xE9, // Usage (Volume Increment)
0x09, 0xEA, // Usage (Volume Decrement)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
I found the way to toggle flight mode in the wireless control section and here a descriptor to it. Still can't find a way to disable the touchpad.
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x0C, // USAGE (Wireless Radio Controls)
0xA1, 0x01, // COLLECTION (Application)
0x85, 0x03, // Report ID (3)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x09, 0xC6, // USAGE (Wireless Radio Button)
0x95, 0x01, // REPORT_COUNT (1
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x06, // INPUT (Data,Var,Rel)
0x75, 0x07, // REPORT_SIZE (7
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0xC0, // END_COLLECTION
Recently I started to work with the M5 Stacks Core 2 and wondered how they displayed images onto the screen. Using an example given for Arduino, I see that the project file contains many '.c' files containing a const unsigned char followed by a series of hex values. Here is an example of one of those files:
const unsigned char image_DigNumber_0000_0[504] = {
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x16, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xc7, 0x11, 0x11, 0x11, 0x11, 0x1e, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x21, 0x11, 0x11, 0x12, 0x34, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x42, 0x11, 0x11, 0x1a, 0xf5, 0x4f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x76, 0xf7, 0x11, 0x11, 0x1c, 0xff, 0x74,
0xff, 0xff, 0xff, 0xff, 0xf7, 0x7f, 0xf7, 0x11, 0x11, 0x1f, 0xff, 0xf7, 0x4c, 0xcc, 0xcc, 0xcc, 0x77, 0xff, 0xf7, 0x11, 0x11, 0x1f, 0xff, 0xfc, 0x11, 0x11, 0x11, 0x11, 0x6f, 0xff, 0xf7, 0x11,
0x11, 0x1f, 0xff, 0xfc, 0x11, 0x11, 0x11, 0x11, 0x7f, 0xff, 0xf7, 0x11, 0x11, 0x1f, 0xff, 0xfc, 0x11, 0x11, 0x11, 0x11, 0x7f, 0xff, 0xf7, 0x11, 0x11, 0x1f, 0xff, 0xfc, 0x11, 0x11, 0x11, 0x11,
0x7f, 0xff, 0xf7, 0x11, 0x11, 0x5f, 0xff, 0xfa, 0x11, 0x11, 0x11, 0x11, 0x7f, 0xff, 0xf5, 0x11, 0x11, 0x5f, 0xff, 0xf7, 0x11, 0x11, 0x11, 0x11, 0x9f, 0xff, 0xf5, 0x11, 0x11, 0x5f, 0xff, 0xf7,
0x11, 0x11, 0x11, 0x11, 0xcf, 0xff, 0xf5, 0x11, 0x11, 0x5f, 0xff, 0xf7, 0x11, 0x11, 0x11, 0x11, 0xcf, 0xff, 0xf5, 0x11, 0x11, 0x6f, 0xff, 0xf7, 0x11, 0x11, 0x11, 0x11, 0xcf, 0xff, 0xf5, 0x11,
0x11, 0x7f, 0xff, 0xf7, 0x11, 0x11, 0x11, 0x11, 0xcf, 0xff, 0xf5, 0x11, 0x11, 0x7f, 0xff, 0xf3, 0x11, 0x11, 0x11, 0x11, 0x7f, 0xff, 0xf2, 0x11, 0x11, 0x7f, 0xfd, 0x41, 0x11, 0x11, 0x11, 0x11,
0x17, 0xff, 0xf1, 0x11, 0x11, 0x2f, 0xd2, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x6f, 0xc1, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x13, 0x31, 0x11, 0x11, 0x56, 0x11, 0x11,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0xef, 0x91, 0x11, 0x11, 0x11, 0x11, 0x11, 0x13, 0xdf, 0x31, 0x11, 0x11, 0xff, 0xfa, 0x11, 0x11, 0x11, 0x11, 0x11, 0x4f, 0xff, 0x71, 0x11,
0x13, 0xff, 0xff, 0x91, 0x11, 0x11, 0x11, 0x13, 0xff, 0xff, 0x71, 0x11, 0x15, 0xff, 0xff, 0xc1, 0x11, 0x11, 0x11, 0x17, 0xff, 0xff, 0x71, 0x11, 0x15, 0xff, 0xff, 0xc1, 0x11, 0x11, 0x11, 0x17,
0xff, 0xff, 0x71, 0x11, 0x15, 0xff, 0xff, 0xc1, 0x11, 0x11, 0x11, 0x17, 0xff, 0xff, 0x51, 0x11, 0x15, 0xff, 0xff, 0xc1, 0x11, 0x11, 0x11, 0x17, 0xff, 0xff, 0x51, 0x11, 0x15, 0xff, 0xff, 0xb1,
0x11, 0x11, 0x11, 0x17, 0xff, 0xff, 0x51, 0x11, 0x17, 0xff, 0xff, 0x71, 0x11, 0x11, 0x11, 0x1c, 0xff, 0xff, 0x51, 0x11, 0x17, 0xff, 0xff, 0x71, 0x11, 0x11, 0x11, 0x1c, 0xff, 0xff, 0x41, 0x11,
0x17, 0xff, 0xff, 0x71, 0x11, 0x11, 0x11, 0x1c, 0xff, 0xff, 0x11, 0x11, 0x17, 0xff, 0xff, 0x71, 0x11, 0x11, 0x11, 0x1c, 0xff, 0xff, 0x11, 0x11, 0x17, 0xff, 0xff, 0x61, 0x11, 0x11, 0x11, 0x1d,
0xff, 0xff, 0x11, 0x11, 0x17, 0xff, 0xf7, 0x7c, 0xcc, 0xcc, 0xcc, 0x47, 0xff, 0xff, 0x11, 0x11, 0x17, 0xff, 0x77, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x6f, 0xfc, 0x11, 0x11, 0x17, 0xfa, 0x7f, 0xff,
0xff, 0xff, 0xff, 0xff, 0x44, 0xf7, 0x11, 0x11, 0x14, 0x97, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0x31, 0x11, 0x11, 0x11, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x11, 0x11, 0x11,
0x11, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
};
It is called in the main code like this:
DisClockbuff.drawColorBitmap(posx[1],26,24,42,
DigNumber[ sytState.Rtctime.Hours % 10 ],
0xff9c00,
0x1a1100);
My question is how did they create this bitmap images and gather its hex values. Additionally, how would I be able to view these individual bitmap images using the hex values. Is it even possible?
I would suggest you to watch Ben Eater's series on the "Worst Video Card" (https://www.youtube.com/watch?v=uqY3FMuMuRo) It will give you some insights into how an image is represented as binary data. Watch from minute 15:00 from the previous link.
It is possible to convert hex to bmp by following this description: https://www.youtube.com/watch?v=Oj1I55Amrsk
If you are patient you could do it manually here: https://hexed.it based on those rules, however, this is suitable for creating a nice C++ or Matlab algorithm, as it has been previously discussed here
how did they create this bitmap images and gather its hex values?
How the image can be created depend on the hardware of the display, more specifically the display driver chip used by the display module. You would have to know the display driver (i.e. reading the data sheet of the display driver) and create library, fonts for using the chip.
I don't know what display M5 Stacks is using, but I have a blog talk about how to create a display library for using a LCD display commonly-known as Nokia 5110 display which uses a display chip called PCD 8544, the blog should give you some insight on how a bitmap image can be created for that particular display chip.
how would I be able to view these individual bitmap images using the hex values?
The answer is maybe. If you know the columns and the rows, and align your data accordingly, you might be able to see roughly the image to be displayed. For example, this is bitmap image of Adafruit's logo for its SSD1306 lcd (which is a 128x64 pixels oled display), when align the data this way, you could vaguely see the star fruit logo from far direct from this data structure, because the data bit (0 or 1) is directly related to the pixel to be displayed on the screen in this case. This however might not be possible, depend on how data is structured (e.g. some display divided the display into page, and within each page, each data byte represent a vertical column on the display).
static const unsigned char PROGMEM logo_bmp[] =
{ 0b00000000, 0b11000000,
0b00000001, 0b11000000,
0b00000001, 0b11000000,
0b00000011, 0b11100000,
0b11110011, 0b11100000,
0b11111110, 0b11111000,
0b01111110, 0b11111111,
0b00110011, 0b10011111,
0b00011111, 0b11111100,
0b00001101, 0b01110000,
0b00011011, 0b10100000,
0b00111111, 0b11100000,
0b00111111, 0b11110000,
0b01111100, 0b11110000,
0b01110000, 0b01110000,
0b00000000, 0b00110000 };
I'm trying to do an HMAC-SHA512 on some data using OpenSSL. I get an "Exception thrown at 0x... (libcrypto-1_1-x64.dll) in Program.exe: 0xC0000005: Access violation writing location 0x..." error when executing the following code:
int main(int argc, char** argv)
{
uint8_t* data[] = { 0x14, 0xf7, 0xbd, 0x95, 0x57, 0x9a, 0x7e, 0xa1, 0x5c, 0xf7, 0x27, 0x91, 0x0d, 0x61, 0x58, 0x01, 0xa3, 0x12, 0x17, 0x54, 0x0b, 0x2e, 0xb4, 0xc5, 0xb1, 0xeb, 0xab, 0xe0, 0x43, 0x9b, 0x8e, 0x1f, 0x39, 0x7d, 0x85, 0x1a, 0x3a, 0x4b, 0x9c, 0xf4, 0xbf, 0x31, 0x55, 0x72, 0x41, 0xf5, 0xdb, 0xcb, 0xb3, 0xa6, 0xb5, 0xb8, 0x82, 0xe5, 0xef, 0x18, 0x72, 0xa0, 0x59, 0x08, 0x9b, 0xfa, 0x17, 0xa3 };
uint8_t* key = "some_rand_pw";
uint8_t* result = malloc(64);
memset(result, 0, 64);
HMAC(EVP_sha512(), key, 12, data, 64, result, (unsigned int)64); //ERROR
}
I would use uint8_t* result = HMAC(EVP_sha512(), key, 12, data, 64, NULL, NULL), but it isn't thread safe, and this will be a multithreaded program. Anyone have any idea what I did wrong here?
I'm using Visual Studio 2017 with 64-bit OpenSSL pre-built for Windows.
Your code is wrong. data must be an array of uint8, but you declared it as an array of pointers to uint8.
Furthermore the last parameter of HMAC must be a pointer to unsigned int but you provided an unsigned int, that's the reason for the crash.
Your compiler should have warned you. Compile with -Wall.
Corrected (untested) code:
int main(int argc, char** argv)
{
uint8_t data[] = { 0x14, 0xf7, 0xbd, 0x95, 0x57, 0x9a, 0x7e, 0xa1, 0x5c, 0xf7, 0x27, 0x91, 0x0d, 0x61, 0x58, 0x01, 0xa3, 0x12, 0x17, 0x54, 0x0b, 0x2e, 0xb4, 0xc5, 0xb1, 0xeb, 0xab, 0xe0, 0x43, 0x9b, 0x8e, 0x1f, 0x39, 0x7d, 0x85, 0x1a, 0x3a, 0x4b, 0x9c, 0xf4, 0xbf, 0x31, 0x55, 0x72, 0x41, 0xf5, 0xdb, 0xcb, 0xb3, 0xa6, 0xb5, 0xb8, 0x82, 0xe5, 0xef, 0x18, 0x72, 0xa0, 0x59, 0x08, 0x9b, 0xfa, 0x17, 0xa3 };
uint8_t* key = "some_rand_pw";
uint8_t* result = malloc(64);
unsigned int len;
memset(result, 0, 64);
HMAC(EVP_sha512(), key, 12, data, 64, result, &len);
}
There is still room for improvement though.
This is my first time using the USR-TCP232-T2 module (TTL-Ethernet converter).
My project is to config and Tx\Rx with the module by the serial port (not the LAN port).
When I send basic parameters config command or port parameters config command, the result is 0xBE 0x45 (Error).
Explanation:
During initialization I send read configuration command.
The module returns 137 bytes as follows:
0x55 0xb - ducSequenceNum[2];
0x00 - ucCRC;
0x00 - ucVersion;
0x00 - UnknownParameter;
0x00 - ucFlags_1;
0x00 0x00 - usLocationURLPort[2];
0x50 0x00 - usHTTPServerPort[2];
0x00 - ucUserFlag;
0x07 0x00 0xa8 0xc0 - ulStaticIP[4];
0x01 0x00 0xa8 0xc0 - ulGatewayIP[4];
0x00 0xff 0xff 0xff - ulSubnetMask[4];
0x55, 0x53, 0x52, 0x2d, 0x54, 0x43, 0x50, 0x32
0x33, 0x32, 0x2d, 0x54, 0x32, 0x00 - ucModName[14];
0x00, 0x00 - ProtocolReserved[2];
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00 - username[6];
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00 - password[6];
0x00 - ucNetSendTime;
0x01, 0x00 - uiId[2];
0x80 - ucIdType;
0xd8, 0xb0, 0x4c, 0xf9, 0xb4, 0x8d - mac_addrs[6];
0xde, 0xde, 0x43, 0xd0 - DNS_Gateway_IP[4];
0x03, 0x00, 0x00, 0x00 - ucReserved_1[4];
0x00, 0xC2, 0x01, 0x00 - ulBaudRate[4];
0x08 - ucDataSize;
0x01 - ucParity;
0x01 - ucStopBits;
0x00 - ucFlowControl;
0x00, 0x00, 0x00, 0x00 - ulTelnetTimeout[4];
0x8C, 0x4E - usTelnetLocalPort[2];
0x2a, 0x20 - usTelnetRemotePort[2];
0x31, 0x39, 0x32, 0x2e, 0x31, 0x36,
0x38, 0x2e, 0x30, 0x2e, 0x32, 0x00,
0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - uiTelnetURL[30];
0xc9, 0x00, 0xa8, 0xc0 - ulTelnetIPAddr[4];
0x20 - ucFlags_2;
0x01 - ucWorkMode;
0x00 - HTPucFlags;
0x04 - tc_number;
0x10, 0x0e - uiPackLen[2];
0x00 - ucPackTime;
0x00 - ucTimeCount;
0x00, 0x00, 0x00, 0x00, 0x00 - ucReserved_2[5];
0xac 0x13 0x01 0x57 - Current_IP[4];
0xb1 - Version;
Now, When I send Basic Parameters config Command, same as in the received configuration:
0x55 - Start byte
0xBE - Basic parameters command code 0x00 - ucSequenceNum
0x00 - ucCRC
0x00, - ucVersion
0x00, - ucFlags - DHCP
0x00, 0x00, - usLocationURLPort[2]
0x50, 0x00, - usHTTPServerPort[2]
0x00, - ucUserFlag
0x07, 0x00, 0xA8, 0xC0, - ulStaticIP[4]
0x01, 0x00, 0xA8, 0xC0, - ulGatewayIP[4]
0x00, 0xFF, 0xFF, 0xFF, - ulSubnetMask[4]
0x55, 0x53, 0x52, 0x2d, 0x54,
0x43, 0x50, 0x32, 0x33, 0x32,
0x2d, 0x54, 0x32, 0x00, - ucModName[14]
0x00, 0x00, - ProtocolReserved[2]
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00, - username[6]
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00, - password[6]
0x00, - ucNetSendTime
0x01, 0x00, - uiId[2]
0x80, - ucIdType
0xd8, 0xb0, 0x4c, 0xf9, 0xb4, 0x8d, - mac_addrs[6]
0xde, 0xde, 0x43, 0xd0, - DNSGatewayIP[4]
0x03, 0x00, 0x00, 0x00 - ucReserved[4]
0xFF - CheckSum
The USR-TCP232-T2 module returns 0xBE 0x45 which indicates some error.
Or, when I send Port Parameters config Command, same as in the received configuration:
0x55 - Start byte
0xBF - Port parameters command code
0x00, 0xC2, 0x01, 0x00, - ulBaudRate[4] - 115200 bps
0x08, - ucDataSize
0x01, - ucParity
0x01, - ucStopBits
0x00, - ucFlowControl
0x00, 0x00, 0x00, 0x00, - ulTelnetTimeout[4]
0x8C, 0x4E, - usTelnetLocalPort[2]
0x2a, 0x20, - usTelnetRemotePort[2]
0x31, 0x39, 0x32, 0x2e, 0x31, 0x36,
0x38, 0x2e, 0x30, 0x2e, 0x32, 0x00,
0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - uiTelnetURL[30]
0xc9, 0x00, 0xa8, 0xc0, - ulTelnetIPAddr[4]
0x20, - ucFlags
0x01, - ucWorkMode
0x00, - HTPucFlags
0x04, - tc_number
0x10, 0x0e, - uiPackLen[2]
0x00, - ucPackTime
0x00, - ucTimeCount
0x00, 0x00, 0x00, 0x00, 0x00 - ucReserved[5]
0xBD - CheckSum
The USR-TCP232-T2 module returns 0xBE 0x45 which indicates some error.
Any help will be appreciated.
Thanks in advance.
I've found the problem.
The code to send the command was:
u8 BasicSettingCom[] = {0x55, 0xBE, &basicParamsStruct, checkSum};
.
.
SendDataToClient((u8*)BasicSettingCom, Length);
So the pointer of basicParamsStruct was sent and not its content.
Now the code to send the command is:
const u8 BasicSettingCmd[] = {0x55, 0xBE};
.
.
SendDataToClient((u8*)BasicSettingCmd, cmdLen);
SendDataToClient((u8*)basicParamsStruct , dataLen);
SendByteToClient(checkSum);
and it works fine.
I guess its very simple but it wasted my time a lot but still no luck!
the following is working very nicely-
sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
byte[] bytes=new byte[]{0x7F, 0x00, 0x00, 0x21, 0x09, 0x7F, 0x30, 0x00, 0x15, 0x02, 0x02, 0x00, 0xEE, 0x28, 0xCB, 0x87 };
sck.Connect("192.168.1.100", 8008);
sck.Send(bytes);
sck.Close();
and, if I keep those array of hex strings in a text box like-
textbox1.Text="0x7F, 0x00, 0x00, 0x21, 0x09, 0x7F, 0x30, 0x00, 0x15, 0x02, 0x02, 0x00, 0xEE, 0x28, 0xCB, 0x87";
But, I need to use the textbox1.Text string for the same task; like-
sck.Send(textbox1.Text);
I tried a lot but could not come up with any solution. Please guide me...
In fact, I'll keep the hex string in the database as string and will be retrieved later in my program.
Firstly, the difference between a string and a byte array is :
"0x03" as a string is of 4 bytes
0x03 as an entry in a byte array is of 1 byte
So what you need to do is Delimit the string at , and separate different hexadecimal strings, store them in a string array or any other data structure.
Then you have to convert these strings to a single byte using some function or you can create your own method, one of them can be found here.
Store these bytes in a byte array and you're good to go.
I did it the following way:
txtHexString.Text="0x11, 0x01, 0x49, 0x4D, 0x41, 0x47, 0x45, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x75, 0x6D, 0x6D, 0x61, 0x72, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00";
string[] namesArray = txtHexString.Text.Split(',');
byte[] abc= new byte [namesArray.Length];
for (int i = 0; i <= namesArray.Length - 1; i = i + 1)
{
abc[i] = Convert.ToByte(namesArray[i].Replace(" ", ""), 16);
}
here, abc is the desired byte array.