Need Help On Touchscreen dos driver

The intent of this forum is to discuss my DOS TSR programs (available at http://bretjohnson.us), how they work and don't work, new/missing features, status of updates, and anything else related to them that may need to be discussed.

Re: Need Help On Touchscreen dos driver

Postby Pierre-Marie Baty » Sat Nov 19, 2016 6:57 am

Okay, so thanks to Bret's information and the Linux driver source code, I figured out how to send a control packet to the touch screen. The values in the 8 bytes of that control/setup packet were copied from the Linux driver source code. Once the int14h returns I retrieve a valid transaction handle and closure ID.

Now that I know how to "talk" to it, I need to know how to "listen". I know for sure that the device is supposed to send me back something after this initialization packet is sent (the docs say so). I'll try and figure out how to read what it sends me myself. If you see this message before I post back, don't hesitate to hint me in the right direction.

BTW. I changed my callback prototype to "void far USBCallback (void)", but now even though it doesn't crash any longer when I pull the USB cord out (that's a progress), it doesn't display what it's supposed to do. My one-line callback function currently just raises a global flag, that the program's main loop should catch so as to print something on the screen saying that the callback has been called. Yet nothing happens. An idea why ?
Pierre-Marie Baty
 
Posts: 6
Joined: Thu Nov 17, 2016 11:05 am

Re: Need Help On Touchscreen dos driver

Postby Pierre-Marie Baty » Sun Nov 20, 2016 6:10 am

TO EVERYBODY USING BORLAND TURBO C++ 3.0

Passing the -mt compiler option as a #pragma directive like this does not work !

#pragma option -a -d -mt
// : : :
// : : +.. tiny memory model
// : +..... merge duplicate strings
// +........ word alignment

Your options will be silently disregarded by the compiler, without a single warning message your program will not behave appropriately.

I couldn't understand why my callback function wasn't called. I spent 4 days on this. Simply passing those compiler options in the command-line rather than in a #pragma directive instantly resolved my problem.

Now you're probably thinking: "dude, if you had disassembled your output you'd have seen the obvious, that it was not compiled in the tiny memory model". Well, I didn't bother, because not all of us know enough of low-level programming to understand 16-bit assembly listing headers. :)

I think I'll create a new thread with that info so that every newcomer sees it.
Pierre-Marie Baty
 
Posts: 6
Joined: Thu Nov 17, 2016 11:05 am

Re: Need Help On Touchscreen dos driver

Postby Pierre-Marie Baty » Mon Nov 21, 2016 10:45 am

Success !

Thanks to Bret's answer and the Linux source code, I managed to write a DOS driver for my eGalax USB Touch screen.

As promised, here's the source code of it. (see attachment)

You will notice that I have written a "usb.h" header that contain :
- all the data definitions (packet types, error types, int14h structure)
- additional structures to wrap up the most common data : driver reply, host info, device info, transaction notification
- wrapper functions to do the most common tasks : check for driver presence, get host info, get device info, register/unregister as interface owner, schedule or cancel a periodic transaction, send a control/setup request...
- wrapper functions to handle USB notifications : you no longer need to supply a callback, the wrapper provides its own. All notifications are stacked up in a global array until you process them in the main loop of your program, using the USB_PopUnprocessedNotification() that chops them one by one from the array.

These modifications make the usbtouch.c source code VERY short and extremely easy to understand, even for beginners. :)

Actually, someone wanting to develop a USB device driver in C without any prior knowledge of USB nor ASM can start from this base. If by luck his device driver also sends data to the host through periodic transactions like this one, then he'll be able to make it work for his device in no time.
Attachments
usbtouch.zip
eGalax USB touch driver program in C. Simplified and commented. Not TSR.
(11.33 KiB) Downloaded 837 times
Pierre-Marie Baty
 
Posts: 6
Joined: Thu Nov 17, 2016 11:05 am

Re: Need Help On Touchscreen dos driver

Postby Bret » Thu Dec 01, 2016 2:16 pm

Glad you got it working!

Sorry, I've been on vacation for the last couple of weeks for the Thanksgiving holiday and haven't been able to check the forum. I'll check out your code and see if I can glean any information I can use for my "generic" driver.
Bret
 
Posts: 478
Joined: Fri Oct 10, 2008 3:43 am
Location: Rio Rancho, NM

Previous

Return to Programs

Who is online

Users browsing this forum: No registered users and 3 guests

cron