This commit is contained in:
forth32 2016-09-22 17:01:57 +03:00
commit da36ef2681
4 changed files with 23 additions and 8 deletions

View File

@ -151,6 +151,7 @@ return 1;
#else
char device[20] = "\\\\.\\COM";
DCB dcbSerialParams = {0};
COMMTIMEOUTS CommTimeouts;
strcat(device, devname);
@ -158,22 +159,32 @@ return 1;
if (hSerial == INVALID_HANDLE_VALUE)
return 0;
ZeroMemory(&dcbSerialParams, sizeof(dcbSerialParams));
dcbSerialParams.DCBlength=sizeof(dcbSerialParams);
if (!GetCommState(hSerial, &dcbSerialParams))
{
CloseHandle(hSerial);
return 0;
}
dcbSerialParams.BaudRate=CBR_115200;
dcbSerialParams.ByteSize=8;
dcbSerialParams.StopBits=ONESTOPBIT;
dcbSerialParams.Parity=NOPARITY;
dcbSerialParams.fBinary = TRUE;
dcbSerialParams.fDtrControl = DTR_CONTROL_ENABLE;
dcbSerialParams.fRtsControl = RTS_CONTROL_ENABLE;
if(!SetCommState(hSerial, &dcbSerialParams))
{
CloseHandle(hSerial);
return 0;
}
CommTimeouts.ReadIntervalTimeout = MAXDWORD;
CommTimeouts.ReadTotalTimeoutConstant = 0;
CommTimeouts.ReadTotalTimeoutMultiplier = 0;
CommTimeouts.WriteTotalTimeoutConstant = 0;
CommTimeouts.WriteTotalTimeoutMultiplier = 0;
if (!SetCommTimeouts(hSerial, &CommTimeouts))
{
CloseHandle(hSerial);
return 0;
}
return 1;
#endif
}
@ -240,6 +251,7 @@ char* pbuf; // буфер для загрузки образа раздела
unsigned char devname[50]="/dev/ttyUSB0";
#else
char devname[50]="";
DWORD bytes_written, bytes_read;
#endif
while ((opt = getopt(argc, argv, "hp:ft:")) != -1) {
@ -266,6 +278,7 @@ printf("\n Утилита предназначена для аварийной U
case 't':
tflag=1;
strcpy(ptfile,optarg);
break;
case '?':
case ':':
@ -342,7 +355,7 @@ for(bl=0;bl<nblk;bl++) {
pktcount=1;
// выделяем память под полный образ раздела
pbuf=malloc(blk[bl].size);
pbuf=(char*)malloc(blk[bl].size);
// читаем образ раздела в память
fseek(ldr,blk[bl].offset,SEEK_SET);

Binary file not shown.

View File

@ -54,6 +54,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -70,6 +71,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -80,7 +82,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="balong-usbdload.c" />
<ClCompile Include="..\..\balong-usbdload.c" />
<ClCompile Include="wingetopt.c" />
</ItemGroup>
<ItemGroup>

View File

@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="balong-usbdload.c">
<ClCompile Include="..\..\balong-usbdload.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wingetopt.c">