Commit 99629d4c authored by David Košenina's avatar David Košenina

callibration ref data updated, certificate write safety

parent 207521ba
......@@ -32,14 +32,14 @@
"stepMin": 460,
"stepMax": 480,
"gainValue": {
"volt2": 1413,
"volt1": 1769,
"mili500": 2120,
"mili200": 2583,
"mili100": 1410,
"mili50": 1763,
"mili20": 2238,
"mili10": 2599
"volt2": 1415,
"volt1": 1771,
"mili500": 2123,
"mili200": 2587,
"mili100": 1412,
"mili50": 1767,
"mili20": 2244,
"mili10": 2608
},
"gainVoltage": {
"volt2": 200,
......@@ -84,134 +84,134 @@
},
"callibratedNormal": {
"offsetsCh0": {
"volt2": 3,
"volt1": 3,
"mili500": -3,
"mili200": -12,
"mili100": 3,
"mili50": 3,
"mili20": -4,
"mili10": -12
"volt2": -47,
"volt1": -48,
"mili500": -51,
"mili200": -60,
"mili100": -47,
"mili50": -48,
"mili20": -52,
"mili10": -61
},
"offsetsCh1": {
"volt2": -38,
"volt1": -40,
"mili500": -39,
"mili200": -43,
"mili100": -38,
"mili50": -40,
"mili20": -40,
"mili10": -43
"volt2": -23,
"volt1": -25,
"mili500": -27,
"mili200": -35,
"mili100": -23,
"mili50": -25,
"mili20": -28,
"mili10": -35
},
"voltageStepCh0": {
"volt2": -1.565110,
"volt1": -0.783541,
"mili500": -0.390944,
"mili200": -0.156411,
"mili100": -0.078266,
"mili50": -0.039178,
"mili20": -0.015649,
"mili10": -0.007823
"volt2": -1.560007,
"volt1": -0.779612,
"mili500": -0.389757,
"mili200": -0.156131,
"mili100": -0.078009,
"mili50": -0.038975,
"mili20": -0.015602,
"mili10": -0.007792
},
"voltageStepCh1": {
"volt2": -1.555900,
"volt1": -0.777344,
"mili500": -0.388984,
"mili200": -0.155633,
"mili100": -0.077793,
"mili50": -0.038871,
"mili20": -0.015571,
"mili10": -0.007780
"volt2": -1.554028,
"volt1": -0.777067,
"mili500": -0.388809,
"mili200": -0.155311,
"mili100": -0.077702,
"mili50": -0.038853,
"mili20": -0.015551,
"mili10": -0.007767
},
"gainValueCh0": {
"volt2": 1414,
"volt1": 1770,
"mili500": 2121,
"mili200": 2584,
"mili100": 1411,
"mili50": 1764,
"mili20": 2239,
"volt2": 1423,
"volt1": 1777,
"mili500": 2129,
"mili200": 2596,
"mili100": 1417,
"mili50": 1768,
"mili20": 2244,
"mili10": 2599
},
"gainValueCh1": {
"volt2": 1417,
"volt1": 1770,
"mili500": 2122,
"mili200": 2586,
"mili100": 1413,
"mili50": 1765,
"mili20": 2238,
"mili10": 2596
"volt2": 1425,
"volt1": 1779,
"mili500": 2129,
"mili200": 2587,
"mili100": 1419,
"mili50": 1770,
"mili20": 2241,
"mili10": 2594
},
"offsetsGenerator": {
"channel0": 2,
"channel1": 4
"channel0": 0,
"channel1": -2
}
},
"callibrated500Mhz": {
"offsetsCh0": {
"volt2": 3,
"volt1": 3,
"mili500": -3,
"mili200": -12,
"mili100": 3,
"mili50": 3,
"mili20": -5,
"mili10": -12
"volt2": -47,
"volt1": -48,
"mili500": -51,
"mili200": -60,
"mili100": -47,
"mili50": -48,
"mili20": -52,
"mili10": -61
},
"offsetsCh1": {
"volt2": -38,
"volt1": -40,
"mili500": -40,
"mili200": -44,
"mili100": -38,
"mili50": -40,
"mili20": -41,
"mili10": -44
"volt2": -22,
"volt1": -23,
"mili500": -23,
"mili200": -25,
"mili100": -22,
"mili50": -23,
"mili20": -24,
"mili10": -25
},
"voltageStepCh0": {
"volt2": -1.565248,
"volt1": -0.783702,
"mili500": -0.390971,
"mili200": -0.156397,
"mili100": -0.078257,
"mili50": -0.039174,
"mili20": -0.015625,
"mili10": -0.007823
"volt2": -1.559967,
"volt1": -0.779591,
"mili500": -0.389756,
"mili200": -0.156112,
"mili100": -0.078005,
"mili50": -0.038975,
"mili20": -0.015601,
"mili10": -0.007793
},
"voltageStepCh1": {
"volt2": -1.556114,
"volt1": -0.777591,
"mili500": -0.388545,
"mili200": -0.155525,
"mili100": -0.077809,
"mili50": -0.038872,
"mili20": -0.015551,
"mili10": -0.007776
"volt2": -1.555050,
"volt1": -0.777616,
"mili500": -0.389141,
"mili200": -0.155562,
"mili100": -0.077740,
"mili50": -0.038889,
"mili20": -0.015540,
"mili10": -0.007778
},
"gainValueCh0": {
"volt2": 1423,
"volt1": 1778,
"mili500": 2127,
"mili200": 2594,
"mili100": 1416,
"mili50": 1770,
"volt1": 1777,
"mili500": 2129,
"mili200": 2596,
"mili100": 1417,
"mili50": 1768,
"mili20": 2242,
"mili10": 2601
"mili10": 2599
},
"gainValueCh1": {
"volt2": 1417,
"volt1": 1771,
"mili500": 2122,
"mili200": 2586,
"mili100": 1413,
"mili50": 1764,
"mili20": 2237,
"mili10": 2594
"volt2": 1424,
"volt1": 1779,
"mili500": 2129,
"mili200": 2588,
"mili100": 1419,
"mili50": 1770,
"mili20": 2239,
"mili10": 2593
},
"offsetsGenerator": {
"channel0": 2,
"channel1": 4
"channel0": 0,
"channel1": -2
}
}
}
\ No newline at end of file
......@@ -611,7 +611,7 @@ int usbFxxTransferDataOut(UsbContext* ctx, int endPoint, char* src, int size, in
return PUREUSB_FAILURE;
}
void usbFxxGuidVidPid(UsbContext* ctx, struct UsbGuid guid, int vendorId, int productId, char serialId)
void usbFxxGuidVidPid(UsbContext* ctx, struct UsbGuid guid, int vendorId, int productId,unsigned int serialId)
{
ctx->guid = guid;
ctx->vendorId = vendorId;
......@@ -644,6 +644,7 @@ int usbFxxFindList(UsbContext* ctx, usbDevice** foundList, int maxCount)
libusb_get_device_descriptor(device, &desc);
if(desc.idVendor == ctx->vendorId && desc.idProduct == ctx->productId)
{
ctx->serialId = desc.iSerialNumber;
foundList[index] = (usbDevice*)device;
index++;
if(index < 0)
......@@ -721,7 +722,9 @@ int usbFxxOpenNormal(UsbContext* ctx, usbDevice** foundList, int maxCount)
libusb_device* device = (libusb_device*)foundList[i];
if(device)
{
return usbFxxOpen(ctx, (usbDevice*)device);
int ret = usbFxxOpen(ctx, (usbDevice*)device);
ctx->serialBufferSize = libusb_get_string_descriptor_ascii(ctx->device, ctx->serialId, ctx->serialBuffer, 1024);
return ret;
}
}
return PUREUSB_FAILURE;
......
......@@ -84,7 +84,9 @@ struct UsbContext
usbDeviceHandle* device;
int vendorId;
int productId;
char serialId;
unsigned int serialId;
char serialBuffer[1024];
int serialBufferSize;
usbCallback callback;
};
typedef struct UsbContext UsbContext;
......
......@@ -425,6 +425,19 @@ void OsciloskopOsciloskop::onActivate(wxActivateEvent& event)
SetIcons(icoBundle);
m_textCtrlFreqDividerOnTextEnter(version2);
if (pOsciloscope->settings.getSettings()->windowDebug != 2)
{
wxMenuItem* item8 = m_menu5->FindItemByPosition(8);
if(item8)
item8->Enable(false);
wxMenuItem* item9 = m_menu5->FindItemByPosition(9);
if (item9)
item9->Enable(false);
wxMenuItem* item10 = m_menu5->FindItemByPosition(10);
if (item10)
item10->Enable(false);
}
}
}
......@@ -3408,35 +3421,44 @@ void OsciloskopOsciloskop::m_menuItemWriteCertificateOnMenuSelection(wxCommandEv
}
else
{
char zeroAll[256] = { 0 };
int ret = usbFx3WriteLockableEEPROM((UsbContext*)getCtx()->usb, (unsigned char*)zeroAll, 256, 0);
if (ret == PUREUSB_SUCCESS)
cJSON* json = cJSON_Parse(src);
bool isValid = json && json->child && json->child[0].next;
if (isValid && SDL_memcmp(json->child[0].next->valuestring, ((UsbContext*)getCtx()->usb)->serialBuffer, ((UsbContext*)getCtx()->usb)->serialBufferSize ) == 0)
{
int ret = usbFx3WriteLockableEEPROM((UsbContext*)getCtx()->usb, (unsigned char*)src, size, 0);
char zeroAll[256] = { 0 };
int ret = usbFx3WriteLockableEEPROM((UsbContext*)getCtx()->usb, (unsigned char*)zeroAll, 256, 0);
if (ret == PUREUSB_SUCCESS)
{
char verify[256] = { 0 };
ret = usbFx3ReadLockableEEPROM((UsbContext*)getCtx()->usb, (unsigned char*)verify, size, 0);
int ret = usbFx3WriteLockableEEPROM((UsbContext*)getCtx()->usb, (unsigned char*)src, size, 0);
if (ret == PUREUSB_SUCCESS)
{
if (SDL_memcmp((unsigned char*)src, verify, size) == 0)
char verify[256] = { 0 };
ret = usbFx3ReadLockableEEPROM((UsbContext*)getCtx()->usb, (unsigned char*)verify, size, 0);
if (ret == PUREUSB_SUCCESS)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Clipboard data written and verifyed tha all written bits match original.", verify, 0);
if (SDL_memcmp((unsigned char*)src, verify, size) == 0)
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Clipboard data written and verifyed tha all written bits match original.", verify, 0);
}
else
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Verifing written bits failed.", verify, 0);
}
}
else
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Verifing written bits failed.", verify, 0);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Reading written bits failed.", "failed", 0);
}
}
else
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Reading written bits failed.", "failed", 0);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Writting bits failed.", "failed", 0);
}
}
else
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Writting bits failed.", "failed", 0);
}
}
else
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Clipboard data serial id does not match usb.", "Serial id is incorrect.", 0);
}
}
}
......
......@@ -672,13 +672,14 @@ int ThreadApi::writeUsbToEEPROM(OscHardware* hw)
setUSB(&usb);
function(afUploadFxx);
wait();
function(afCloseUsb);
wait();
openUSB(hw);
function(afOpenUsb);
wait();
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Writting FX3 will start.", "Please wait and do not disconnect USB.",0 );
function(afEEPROMWrite);
wait();
}
int iret = result(afOpenUsb) + result(afUploadFxx) + result(afEEPROMWrite);
if (iret == SCOPEFUN_SUCCESS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment