Sending UART command to barcode scanner

I am having trouble sending a command to a barcode scanner. I have set up an arduino Mega 2560 to read the barcode scanner properly when the button on the scanner is pressed, but I want it to scan when I send a command from the arduino. The scanner uses uart communication. The data sheet for the scanner says to send the command “7E 00 08 01 00 02 01 AB CD” to tell the scanner to scan.

Here is what the data sheet says specifically.

"In command mode, scanner will begin scanning after receiving the command from
MCU. (That is set bit0 to 1 on address 0x0002).
Note: The scanning command (UART) is that: 7E 00 08 01 00 02 01 AB CD. The
scanner module will response bytes (02 00 00 01 00 33 31) for the command and
begin scanning at the same time.

I have been looking into uart communication and serial communication but I don’t understand how this is supposed to be sent. I have tried sending it by .write and .print sending it as a string but that didn’t work. I am assuming it shouldn’t be sent as a string but I don’t know how else to send it. I tried sending the integers as individual bytes but that didn’t work. I don’'t know what the 7E and the AB CD terms mean.

The data sheet can be found here Barcode Scanner Module - Waveshare Wiki

Here is my code

#include <SoftwareSerial.h>

//Serial Communication for the barcode scanner
SoftwareSerial ScannerSerial(11, 12); // RX, TX

//Serial Monitor
bool typeStringComplete = false; 
String typeString = "";

//ScannerSerial Barcode Scanner
String scannerString = "";  
bool scannerComplete = false; 
int strglength = 0;
int oldstrglength = 0;
long productcode;    //barcode must contain integers only


void setup() {
  ScannerSerial.begin(9600); 
  Serial.begin(9600);

  Serial.println("Start Scanning");
}


void loop() {


 ////Comanding the Barcode Scanner to scan/////
 //when the word "scan" is sent thru the serial monitor
  if (typeStringComplete) {
    if(typeString.startsWith("scan")){
      Serial.println("Scanning...");

 /// ****Problem is here*****//
 /// 7E 00 08 01 00 02 01 AB CD :code from data sheet
    ScannerSerial.write("7E 00 08 01 00 02 01 AB CD");    
    }
 
  else { Serial.println("Invalid Command"); }
      typeString = "";  //clear the string
    typeStringComplete = false;
  }


///Recieving data from the Barcode Scanner///
   oldstrglength = scannerString.length(); 
  if (ScannerSerial.available()) {
  char c =  (char)ScannerSerial.read();
  scannerString  += c;
  }
  strglength = scannerString.length();
     
  if (strglength == oldstrglength && strglength != 0) {
  scannerComplete = true;
  }
  if (scannerComplete) {
    productcode = scannerString.toInt();
     Serial.print("Product Code: ");
    Serial.println(scannerString);
    scannerString = ""; // clear the string:
    scannerComplete = false;
  }
  delay(5);   
}


//Reading the Serial Monitor 
void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    typeString += inChar;
    if (inChar == '\n') {
      typeStringComplete = true;
    }
  }
}

The code sends the command to the scanner when the word “scan” is sent to the arduino through the serial monitor

" If you want to test the UART interface with PC, you require an TTL to
USB board like our CP2102 (should be purchased separately). "

Does the module itself output TTL levels?

The numbers are hexadecimal values for bytes. 1 Byte = 8 bits = 2 nibble
1 nibble = 4 bits (16 values) = numbers from 0 to 9 and A,B,C,D,E,F

e.g. hexadecimal 0 = binary 0000, 1 = 0001, 2 = 0010, … , A = 1010, E = 1110, F = 1111

You can send a byte with Serial.write() and use the hexadecimal notation. The scanning command uses 9 bytes. You send one after another.

Serial.write( 0x7E );
Serial.write( 0x00 );
Serial.write( 0x08 );

You can uses Windows Calc in Programmer Mode and convert numbers from hexadecimal to decimal or binary or use Google.

It worked with the hexadecimal format.
For the Serial.write(0x00); values I kept getting an error. I had to use Serial.write(static_cast(0x00)) and now it works
Thanks