Из сообщения удален лишний параметр и вывод в файл изменен на бинарный
This commit is contained in:
parent
8dc759164b
commit
7097643b77
21
APP/main.c
21
APP/main.c
|
|
@ -233,19 +233,20 @@ int main(int argc, char *argv[]) {
|
|||
uint8_t msdEncoded[512] = {0};
|
||||
|
||||
msdEncoded[0] = 0;
|
||||
msdEncoded[1] = 15;
|
||||
memcpy(&msdEncoded[2], "000000000000000", 15);
|
||||
msdEncoded[17] = strlen(phoneJS->valuestring);
|
||||
memcpy(&msdEncoded[18], phoneJS->valuestring, strlen(phoneJS->valuestring));
|
||||
// msdEncoded[1] = 15;
|
||||
memcpy(&msdEncoded[1], "000000000000000", 15);
|
||||
msdEncoded[16] = strlen(phoneJS->valuestring);
|
||||
memcpy(&msdEncoded[17], phoneJS->valuestring, strlen(phoneJS->valuestring));
|
||||
|
||||
msdEncoded[18 + strlen(phoneJS->valuestring)] = 0;
|
||||
size_t msdEncodedSize = EraGlonassMsdEncode(&msd, MSD_V_2, &msdEncoded[20 + strlen(phoneJS->valuestring)]);
|
||||
msdEncoded[19 + strlen(phoneJS->valuestring)] = msdEncodedSize;
|
||||
msdEncoded[17 + strlen(phoneJS->valuestring)] = 0;
|
||||
size_t msdEncodedSize = EraGlonassMsdEncode(&msd, MSD_V_2, &msdEncoded[19 + strlen(phoneJS->valuestring)]);
|
||||
msdEncoded[18 + strlen(phoneJS->valuestring)] = msdEncodedSize;
|
||||
|
||||
char egtsHexStr[1024] = {0};
|
||||
size_t egtsHexStrLen = 0;
|
||||
vAsciiStringAddBytesAsHex(egtsHexStr, &egtsHexStrLen, msdEncoded, 20 + strlen(phoneJS->valuestring) + msdEncodedSize);
|
||||
vAsciiStringAddBytesAsHex(egtsHexStr, &egtsHexStrLen, msdEncoded, 19 + strlen(phoneJS->valuestring) + msdEncodedSize);
|
||||
|
||||
size_t egtsBinStrLen = 19 + strlen(phoneJS->valuestring) + msdEncodedSize;
|
||||
|
||||
FILE *output_file = fopen(argv[2], "w");
|
||||
if (output_file == NULL) {
|
||||
|
|
@ -254,9 +255,9 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
size_t bytes_written = fwrite(egtsHexStr, 1, egtsHexStrLen, output_file);
|
||||
size_t bytes_written = fwrite(msdEncoded, 1, egtsBinStrLen, output_file);
|
||||
|
||||
if (bytes_written != egtsHexStrLen) {
|
||||
if (bytes_written != egtsBinStrLen) {
|
||||
printf("Error: Failed to write file %s\n", argv[2]);
|
||||
fflush(stdout);
|
||||
return 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue