Skip to content

Commit 266587c

Browse files
committed
GUI messages working, device errors not handled
1 parent 5155113 commit 266587c

2 files changed

Lines changed: 48 additions & 21 deletions

File tree

JavaGUI/ExtIO_RTL.exp

0 Bytes
Binary file not shown.

TSDRPlugin_ExtIO/TSDRPlugin_ExtIO/TSDRPlugin_ExtIO.cpp

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,53 @@ extern "C" void callback(int cnt, int status, float IQoffs, void *IQdata) {
126126
tsdr_cb(outbuf, cntvalues, tsdr_ctx, 0);
127127
}
128128

129+
DWORD WINAPI doGuiStuff(LPVOID arg) {
130+
//AFX_MANAGE_STATE(AfxGetAppModuleState());
131+
132+
if (source->OpenHW()) {
133+
printf("Opened device yey"); fflush(stdout);
134+
135+
// list attenuators
136+
if (source->GetAttenuators != NULL) {
137+
max_att_id = 0;
138+
float att;
139+
while (source->GetAttenuators(max_att_id++, &att) == 0) {};
140+
}
141+
142+
if (source->ShowGUI != NULL)
143+
source->ShowGUI();
144+
//RETURN_OK();
145+
}
146+
else {
147+
closeextio();
148+
//RETURN_EXCEPTION("The ExtIO driver failed to open a device. Make sure your device is plugged in and its drivers are installed correctly.", TSDR_CANNOT_OPEN_DEVICE);
149+
}
150+
151+
152+
153+
MSG msg;
154+
BOOL bRet;
155+
156+
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
157+
{
158+
if (bRet == -1)
159+
{
160+
// handle the error and possibly exit
161+
printf("Errorrrr\n"); fflush(stdout);
162+
}
163+
else
164+
{
165+
printf("Sending messages\n"); fflush(stdout);
166+
167+
TranslateMessage(&msg);
168+
DispatchMessage(&msg);
169+
}
170+
}
171+
172+
return 0;
173+
}
174+
129175
extern "C" int TSDRPLUGIN_EXTIO_API __stdcall tsdrplugin_init(const char * params) {
130-
AFX_MANAGE_STATE(AfxGetAppModuleState());
131176

132177
if (outbuf == NULL) {
133178
outbuf = (float *)malloc(sizeof(float));
@@ -154,26 +199,8 @@ extern "C" int TSDRPLUGIN_EXTIO_API __stdcall tsdrplugin_init(const char * param
154199
RETURN_EXCEPTION("The sample format of the ExtIO plugin is not supported.", TSDR_CANNOT_OPEN_DEVICE);
155200
}
156201

157-
if (source->OpenHW()) {
158-
//printf("Opened %s model %s!\n", name, model); fflush(stdout);
159-
160-
printf("Showing GUI :) \n"); fflush(stdout);
161-
if (source->ShowGUI != NULL) source->ShowGUI();
162-
printf("Yey! \n"); fflush(stdout);
163-
164-
// list attenuators
165-
if (source->GetAttenuators != NULL) {
166-
max_att_id = 0;
167-
float att;
168-
while (source->GetAttenuators(max_att_id++, &att) == 0) {};
169-
}
170-
171-
RETURN_OK();
172-
}
173-
else {
174-
closeextio();
175-
RETURN_EXCEPTION("The ExtIO driver failed to open a device. Make sure your device is plugged in and its drivers are installed correctly.", TSDR_CANNOT_OPEN_DEVICE);
176-
}
202+
CreateThread(NULL, 0, doGuiStuff, NULL, 0, NULL);
203+
RETURN_OK();
177204
}
178205
else {
179206
closeextio();

0 commit comments

Comments
 (0)