Took me the whole damn night but.... Got it working like a charm
Why isn't there any touchscreen driver in freebsd i could use the protocol from..
I ended up writing it all.. Kernel driver for touchscreen and hardware control, make up a protocol for absolute-input device plus xorg input driver to make it all work there.
It was fun.. it's the first freebsd 8 and xorg input driver i've written..
Kernel driver detects double tab, hold (to right click) and swipes (8 directions)
Swipes left/right give me diverent workspaces, up/down i'll make it do scrolling.
Also i'm building gestures in the driver.. like a circle will rotate Xorg
Some running information;
Shift# uname -a
FreeBSD Shift.parawebs.nl 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009 [email protected]:/usr/obj/usr/src/sys/GENERIC i386
Shift# ls -l /dev/ts0
crw------- 1 root wheel 0, 42 Dec 10 14:10 /dev/ts0
Shift# sysctl -a | grep ts\.0
dev.ts.0.%desc: HTC Shift Touchscreen
dev.ts.0.%driver: ts
dev.ts.0.%location: handle=\_SB_.PCI0.SBRG.EC2_
dev.ts.0.%pnpinfo: _HID=PNP0CC0 _UID=0
dev.ts.0.%parent: acpi0
Shift# pciconf -lv
[email protected]:0:0:0: class=0x060000 card=0x10015567 chip=0x27a08086 rev=0x03 hdr=0x00
vendor = 'Intel Corporation'
device = '955XM/945GM/PM/GMS/940GML Express Processor to DRAM Controller'
class = bridge
subclass = HOST-PCI
[email protected]:0:2:0: class=0x030000 card=0x10015567 chip=0x27a28086 rev=0x03 hdr=0x00
vendor = 'Intel Corporation'
device = 'Mobile 945GM/GU Express Integrated Graphics Controller'
class = display
subclass = VGA
[email protected]:0:2:1: class=0x038000 card=0x10015567 chip=0x27a68086 rev=0x03 hdr=0x00
vendor = 'Intel Corporation'
device = 'Mobile 945GM/GU Express Integrated Graphics Controller'
class = display
[email protected]:0:27:0: class=0x040300 card=0x10015567 chip=0x27d88086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) High Definition Audio'
class = multimedia
subclass = HDA
[email protected]:0:29:0: class=0x0c0300 card=0x10015567 chip=0x27c88086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) USB Universal Host Controller'
class = serial bus
subclass = USB
[email protected]:0:29:1: class=0x0c0300 card=0x10015567 chip=0x27c98086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) USB Universal Host Controller'
class = serial bus
subclass = USB
[email protected]:0:29:2: class=0x0c0300 card=0x10015567 chip=0x27ca8086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) USB Universal Host Controller'
class = serial bus
subclass = USB
[email protected]:0:29:7: class=0x0c0320 card=0x10015567 chip=0x27cc8086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) USB 2.0 Enhanced Host Controller'
class = serial bus
subclass = USB
[email protected]:0:30:0: class=0x060401 card=0x10015567 chip=0x24488086 rev=0xe2 hdr=0x01
vendor = 'Intel Corporation'
device = '82801 Family (ICH2/3/4/5/6/7/8/9-M) Hub Interface to PCI Bridge'
class = bridge
subclass = PCI-PCI
[email protected]:0:31:0: class=0x060100 card=0x10015567 chip=0x27b98086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801GBM (ICH7-M) LPC Interface Controller'
class = bridge
subclass = PCI-ISA
[email protected]:0:31:1: class=0x01018a card=0x10015567 chip=0x27df8086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) Ultra ATA Storage Controller'
class = mass storage
subclass = ATA
[email protected]:0:31:3: class=0x0c0500 card=0x10015567 chip=0x27da8086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801G (ICH7 Family) SMBus Controller'
class = serial bus
subclass = SMBus
[email protected]:1:6:0: class=0x080500 card=0x44332211 chip=0x47431947 rev=0x09 hdr=0x00
class = base peripheral
subclass = SD host controller
Shift# usbconfig list
ugen0.1: <UHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen1.1: <UHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen2.1: <UHCI root HUB Intel> at usbus2, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen3.1: <EHCI root HUB Intel> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
ugen3.2: <USB 2.0 Camera Sonix Technology Co., Ltd.> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
ugen0.2: <Fingerprint Sensor vendor 0x08ff> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
ugen3.3: <product 0x005a vendor 0x0409> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE
ugen3.4: <product 0x7720 vendor 0x0b95> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON
ugen2.2: <product 0x0001 vendor 0x0a12> at usbus2, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON
Shift# kldstat
Id Refs Address Size Name
1 38 0xc0400000 b6dfe0 kernel
2 1 0xc0f6e000 1b7b4 snd_hda.ko
3 2 0xc0f8a000 567c0 sound.ko
4 1 0xc0fe1000 4340 ichsmb.ko
5 2 0xc0fe6000 2c8c smbus.ko
6 1 0xc0fe9000 3d80 ichwd.ko
7 1 0xc0fed000 6778 ng_ubt.ko
8 6 0xc0ff4000 d9f4 netgraph.ko
9 2 0xc1002000 df6c ng_hci.ko
10 4 0xc1010000 23a0 ng_bluetooth.ko
11 1 0xc1013000 2d60 ts.ko
12 1 0xc4cb9000 9000 i915.ko
13 1 0xc4cd0000 14000 drm.ko
14 1 0xc6597000 f000 ng_l2cap.ko
15 1 0xc65a8000 21000 ng_btsocket.ko
16 1 0xc65d3000 4000 ng_socket.ko
Touchscreen works perfect now.. after a bit of needed sleep i found out what i was doing wrong with the button mapping and fixed it.
I can now move stuff (windows), select stuff (make selection box), double-tap to double click and hold to right click
Swipes are registered in the kernel module but not yet sent to xorg (swipe screen to scroll / select workspace)
Bluetooth works;
Shift# hccontrol inquiry
Inquiry result, num_responses=1
Inquiry result #0
BD_ADDR: 00:21:09:d8:d1:2e
Page Scan Rep. Mode: 0x1
Page Scan Period Mode: 0x2
Page Scan Mode: 00
Class: 5a:02:0c
Clock offset: 0x170c
Inquiry complete. Status: No error [00]
G-Sensor: I will write a driver for it this weekend.
Fingerprint reader: I'll try and make this one too.
High resolution: Need to decompile some stuff to find out how to trigger it.
3G: will work on it in the weekend
WiFi: Can't seem to activate mine anymore.. i'm guessing a hardware defect
I'm keeping the touchscreen kernel module & driver in alpha status while cleaning it up and add a few more features.
If anyone FreeBSD lover wants to try this on his/her shift contact me for alpha the drivers.
Also if more ppl like to help making drivers for the shift.. you are welcome!
More updates will follow here when i get more stuff working
I'm ecstatic about this. Keep up the good work.
wouhou great news!
Hi,
do you plan to release your drivers ?
i m really interested
thanks a lot
That is really great work
Im not a *nix user , but I understand the beauty of what you are doing!
Great job!
hi do you have news ?
i m really interested
thanks
okay, this is really nice,
is there any possibility to port this to fedora or ubuntu?
i really like those distro's.
nevertheless i would like to look into your sources after you finish cleanup,
i'm cheering for you!
Forgot about this topic
Hi there,
Sorry i kinda forgot this topic.
My Shift is still running FreeBSD and it still runs fine.
I'll pack the drivers and upload them here for anyone to mess with.
Touchscreen kernel module
Here is the kernel module to create the /dev/ts0 device for userland to talk to.
There's also a simple control utility to change some button settings/timings in the module on the fly.
You need to move the ts folders to the kernel source tree in the right location.
/usr/src/sys/modules
and
/usr/src/sys/dev
then type
cd /usr/src/sys/modules/ts && make && make install && kldload ts
To compile the control utility type
gcc tscontrol.c -o tscontrol
ps. the swipe debug messages are still visible in this version.. you may want to change that in ts.c before you compile it
I'll upload the xorg input driver in a minute.
xorg driver for ts module
Here is the xorg input driver that talks to my kernel module via /dev/ts0.
Extract it and type
cd ParaTouch && make && make install
add it to your xorg.conf like this;
Code:
Section "InputDevice"
Identifier "TouchScreen"
Driver "void" # oops i forgot to rename the sceleton :(
Option "Buttons" "5"
Option "ZAxisMapping" "4 5"
Option "MinX" "15"
Option "MaxX" "2000"
Option "MinY" "110"
Option "MaxY" "1940"
Option "Device" "/dev/ts0"
EndSection
Calibrate with changing MinX -- MaxY.
(the forum only accepts zip archives so i had to zip the tar)
Wow amazing work. Had to join this silly forum just to download your code.
Has this been made available to the FreeBSD base? I think there are a lot of folks over there who would be quite interested.
segfault007 said:
Had to join this silly forum just to download your code.
Click to expand...
Click to collapse
Wow. Classy.
This "silly" forum was the only way for you to get that code.
But apparently that didn't register when you wrote your post.
*shakes head*
Very very nice!!!
I know this is kinda an old thread at this point but if you are still monitoring it, I was wondering if you knew/know if this driver will work with other touchscreens?
Reason I ask is I have a Samsung Q1 Ultra that I would love to load FBSD on, the only thing holding me back is no working touchscreen. I was intending to use it as a Media Remote locked on a web page that does the actual "work"
Right now I am using Linux on it but would MUCH MUCH prefer to use FBSD instead as I really prefer FBSD over linux
BSD for SurfacePro
Hi OS,
Do you know how this can be done for the Surface Pro? Using say... PC-BSD.
thanks,
Anan
Do want
I would be fascinated to see this running - BSD has always been my preference
Curious, I'm not familiar with the Shift, is it an android device?
Related
Hi everybody
I tried to achieve a handle for readFile/writeFile operations using lineGetID.
The call to the function passed without errors. My problem is that the handle that I get is 0..., and I should make IO operations some how...
My code:
lRet := lineGetID( FLineHandle, 0, 0, LINECALLSELECT_LINE, PVarString, szClassType );
if lRet = 0 then
begin
FDevHandle := (LPHANDLE(PByte(PVarString) + PVarString^.dwStringOffset ))^;
// some more non relevant code which checks the validity of FDevHandle....
end;
The call to lineGetID is done after successful call to lineGetOpen. I test my application on i-mate jam with WM2003.
Thanks ahead
Kobi
I solved the problem
Hi everybody
For those who encounters the same problem as mine here is the solution that I finally found:
1. The Handle is NULL if we call the lineGetID using LINECALLSELECT_LINE. We should call lineGetID after getting into the LINECALLSTATE_CONNECTED state and use the LINECALLSTATE_CALL parameter. This information was found in the MSDN.
2. The lineGetID (as well as other line functions) doesn't report (I use TAPI 2.0 with WM-2003 on i-mate jam - the cellular line channel) the error LINEERR_STRUCTURETOOSMALL, so immediately after calling the lineGetID I added the following line (I use free pascal compiler):
if (Result = 0) and (PVarString^.dwTotalSize < PVarString^.dwNeededSize) then
Result := integer(LINEERR_STRUCTURETOOSMALL);
After this line comes the characteristic TAPI code which checks if either we should reallocate the previous block, or we can already use the data that call should have given to us.
Just after considering these 2 issues I got a vaild Handle...
Kobi
Hi Kobi,
I also having difficulties creating handle to write data on this TAPI Line, Can you please help me translate your code in VB.NET or C#, I am using VB and C# on developing application in WM2003.
Many thanks in Advance,
Eefendi
More complete code
Hi Eefendi
I neither know VB.NET nor C#, so it will be in Pascal, but I will add comments.
The code itself should be activated after you received the LINE_CALLSTATECONNECTED message/event (depends on the mechanism you selected when you called lineInitialize).
The CallHandle is a variable holds the handle of the call you want to achieve a handle to its stream (you achieve CallHandle, in incoming call for example, using LINE_CALLSTATEOFFERING message/event). The final result we want is stored in Handle. The line itself should be opened using "comm" or "comm/datamodem" class type.
var
VarSize,
Res : integer;
PVarString : LPVARSTRING;
szClassType : PWideChar = 'comm/datamodem';
// these variables definitions is equivalent to the following C code:
// int VarSize, Res;
// LPVARSTRING PVarString;
// TCHAR *szClassType = "comm/datamodem";
begin
VarSize := sizeof(VARSTRING);
Handle := 0;
repeat
GetMem( PVarString, VarSize ); // alloc VarSize bytes
PVarString^.TotalSize := VarSize;
Res := lineGetID( 0, 0, CallHandle, LINECALLSELECT_CALL, PVarString, szClassType );
if (Res = 0) and (PVarString^.TotalSize < PVarString^.NeededSize) then
Res := LINEERR_STRUCTURETOOSMALL;
if Res = LINEERR_STRUCTURETOOSMALL then
VarSize := PVarString^.NeededSize
else
if Res = 0 then // no error
Handle := LPHANDLE(PByte(PVarString) + PVarString^.dwStringOffset)^;
FreeMem( PVarString, PVarString^.TotalSize ); // free memory
until Res <> LINEERR_STRUCTURETOOSMALL; // finish the repeat until loop if this condition is TRUE
if (Handle <> 0) and (Handle <> INVALID_HANDLE_VALUE) then
//;use it as you wish....
end;
Some help to you for conversion:
1. PVarString^.TotalSize using C means PVarString->TotalSize
2. PByte using C means char*
3. type cast for example to PByte is done by PByte(...) while using C it is done by (PByte)...
4. Refering to a value which is referenced by the pointer P and storing it in variable X is done by "X := P^;". using C it is done by "X = *P;".
5. The operator <> means not equal. in C it is !=.
I hope it will be easy to you to translate it to C or any other language you want.
Good luck with your project.
Kobi
TAPI does seem to pop up a lot.
Have you looked at my code I posted a while back here ?
http://forum.xda-developers.com/viewtopic.php?t=18978
Hi Vangelderp and Kobi,
thanks for spending your time answering my questions and also thanks for the code provided. I use VB.Net 2003 on programming my pocket PC 2003, you guys provide me the code using pointer data type which is not supported in VB.net, so I am having trouble converting it. ( When I was learning C++, pointer is always make me confuse :roll: ). I wish you guys will be kind enough helping me convert it to VB.Net, just for small part to get Handle. :wink:
Mant Thanks in advance,
Eefendi
Hi Guys,
I'm going through the forum, I'm new to embedded developement, I've been able to do my first MessageBox("Hello World") in C using VS2005.
I want to understand how all this works, like :
- Accessing any "mass storage" device ? (the root FS ?, /, c:\, whatevername )
- Dumping the whole registry + values.
- Logging Process and activity even while "device locked" (new process, etc..)
And having more knownledge about the internals and devices, booting etc..
I'm kind of lost and my embedded knowledge is very thin..
The PPC i have is running WM5 on QTEK9100 (SPVM3000)..
Any pointers, posts, sources, small explication are more than welcome...
Hope you can help,
Regards,
r.
Welcome!
Wow those sure are some heavy requests for someone who is just starting.
How much experience do you have with C and Win32 APIs?
To start you off here is an excellent site for Windows Mobile programming tips and tricks:
www.pocketpcdn.com
Couple more pointers:
Device root is "\", no drives (SD cards mounted as folders) kind of like Linux.
All path are absolute - no ".\" or ".."
You can use standard C or Win32 functions for file operations.
Registry functions are also same as Desktop windows except you have to use the "Ex" version of of the function.
Example:
RegOpenKey - not implemented, use RegOpenKeyEx.
For process lists etc, google for ToolHelp32.
Thanks,
I'm at ease w/ ANSI C, have some familiarity w/ Win32 APIs,
but as far as I'm seeing I'm trying to code on Win32 Intel First,
then i try to "port" it to PocketPC Mobile, sometime it works
sometime functions doesn't even exists... MSDN doesn't seems very consistent over Win32 vs WM, but as I'm new I guess i'm missing a lot..
WinMain() prototype changes according to your target...otherwise
VS2005 yell about Overloading WinMain, It is VERY annnoying..anyway
Thanks for the links and the *Ex trick, I'll try to get deeper with this.
I have a strange problem trying to do my Own MessageBoxPrintf:
int MessageBoxPrintf(int, const char * title, const char * fmt, ...)
{
va_list ap;
char * buffer = NULL;
/* formatting and fixed size yes...*/
buffer = (char *) malloc (1024 * sizeof(char));
if (!buffer)
return -1;
memset(buffer, 0, 1024);
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
MessageBox(NULL, (LPCWSTR)buffer, (LPCWSTR)title, type);
return 0;
}
It does compile, but it display craps, since there is no stderr,stdout,stdin and
that I'm mostly coding on Win32/VMware, I don't know how to debug on my PPC (no USB connection), and I have no idea what's wrong.. it might be obvious, but it's late..
As I don't know what LPCWSTR stand for, I assumed char * and it did work on Win32 (XP) without hassle (except LPCWSTR types which are wrong for Win32 Target), so why it doesn't on WM5... is a mystery for me now..
Hope to be on speed ASAP to be able to release some stuff..
Thanks for your help,
Cheers,
r.
all WinAPI function on Pocket PC works with Unicode strings. So you have to convert from ANSI to Unicode.
ok, does the TEXT() macros convert to Unicode string, it seems not.
How to convert from ANSI to Unicode ?
you can work directly with wchar_t or use tchar that can be ansi or unicode, otherwise look for MultiByteToWideChar or CString object _T and TEXT Macro aren't for converting ansi but they makes unicode prefix strings... for example MessageBox(hWnd,_T("Hello World"),_T("my messagebox"),MB_OK);
I hope this help and don't forget MSDN have all replies
have fun,
Guybrush
ok it works! thanks!
just another question, how to dump the "disk" or how those devices are booting ROM?/Flash?
Currently I'm copying all the files from / to the SD card mount point is there anything else?
again thanks for your help.
++
r.
I am trying to create a managed wrapper(.net) for the CT810(incite) accelerometer, just hit the wall--
I have dumped my ROM, and extracted the accelsensor.dll
but am unable to extract any signatures
I though I get lucky and just be able to tlbimp it, no such luck
next tried dumpbin /EXPORTS accelsensor.dll
Dump of file accelsensor.dll
File Type: DLL
Section contains the following exports for ACCELSENSOR.dll
00000000 characteristics
2C05A62B time date stamp Thu May 27 22:42:03 1993
0.00 version
1 ordinal base
11 number of functions
11 number of names
ordinal hint RVA name
1 0 000015E0 ACC_Close
2 1 0000141C ACC_Deinit
3 2 000021CC ACC_IOControl
4 3 00001F40 ACC_Init
5 4 000015DC ACC_Open
6 5 00001520 ACC_PowerDown
7 6 00001574 ACC_PowerUp
8 7 000015E8 ACC_Read
9 8 00001618 ACC_Seek
10 9 00001600 ACC_Write
11 A 00001620 DllEntry
Summary
1000 .CRT
1000 .data
1000 .pdata
1000 .reloc
4000 .text
But this does not show any vector data I could subscribe to
Does PEBrowse work with ARM?
Any advice on what to do next?
Regards
_Eric
could you please post the dll for others to work with?in no dev but have been looking forapps that will work with the incite accelerometer but most are made for HTC. you have a step up on most you the fist ive seen in past 4mo of looking who even trying hopefullu little team work with some guys who developed few apps that work with htc g sensor.if you could repost this with included dll. thanks
I now own a LG GM750 (WM6.5) and it also uses the accelsensor.dll.
Some MS applications like IE6 and picture viewer use it when turning the phone but all the nice HTC apps are not working.
There is HTCEmu for Samsung which probably could be adapted for LG.
Anybody trying to do this ?
Hmm.. since this old thread was bumped, I just wanted to link this for reference if it's helpful:
http://www.lg-incite.com/index.php?topic=2791.0
dll & mbn are at 3rd post
Hi
first sry 4 my englisch im german.
Im very interested to get the motion/g-sensor to work with htc apps. I got my lg last week and have the same problem that no apps work on it exepting ie and some windows apps.
If i can help to post some detail or if somehone has a conclusion how to use plz help.
i testet the samsung emu but it do not work also.
THX much
attached the.dll of the lg gm750 in case they serve of something
solution for LG GM750
First take a look at the Unified Sensor Api at codeplex.
My solution is based on the Samsung sensor class, modified to meet the peculiarities of the LG GM750.
First of all, the import of the DeviceIoControl in NativeMethods.cs must be modified such way dwIoControlCode is type uint, and the buffers are byte:
Code:
[DllImport("coredll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, [In] byte[] inBuffer, int nInBufferSize, [Out] byte[] outBuffer, int nOutBufferSize, ref int pBytesReturned, IntPtr lpOverlapped);
After a long time dissassembling the accelsensor.dll and and a lot of trial and error testing I came to this conclusion that works:
The constant that starts/stops data output becomes:
Code:
const uint ACCOnRot = 0x1014EE8;
const uint ACCOffRot = 0x1014EE8;
and for reading values:
Code:
const uint ACCReadValues = 0x1014F10;
The difference between start and stop comes from the input given in DeviceIoControl method as follows:
Code:
public static LGAccSensor Create()
{
DeviceIoControl(ACCOnRot, new byte[1] {1}, new byte[4] );
return new LGAccSensor();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
DeviceIoControl(ACCOffRot, new byte[1] {0}, new byte[1] );
}
The DeviceIoControl inside the accelerometer class becomes
Code:
public static void DeviceIoControl(uint controlCode, byte[] inBuffer, byte[] outBuffer)
{
IntPtr file = NativeMethods.CreateFile("ACC1:", 0, 0, IntPtr.Zero, ECreationDisposition.OpenExisting, 0, IntPtr.Zero);
if (file == (IntPtr)(-1))
throw new InvalidOperationException("Unable to Create File");
try
{
int bytesReturned = 0;
int inSize = sizeof(byte) * inBuffer.Length;
int outSize = sizeof(byte) * outBuffer.Length;
if (!NativeMethods.DeviceIoControl(file, controlCode, inBuffer, inSize, outBuffer, outSize, ref bytesReturned, IntPtr.Zero))
throw new InvalidOperationException("Unable to perform operation.");
}
finally
{
NativeMethods.CloseHandle(file);
}
}
Note that the accelerometer device is called ACC1:.
Further the method that returns the three component vector becomes
Code:
public override GVector GetGVector()
{
byte[] outBuffer = new byte[4];
DeviceIoControl(ACCReadValues, new byte[1] {1}, outBuffer);
GVector ret = new GVector();
int accx = outBuffer[2];
if (accx <=31)
ret.X = accx/2.17;
else
ret.X = (accx-64)*0.47;
ret.X = -ret.X;
int accy = outBuffer[1] ;
if (accy <=31)
ret.Y = accy/2.17;
else
ret.Y = (accy - 64) * 0.47;
int accz = outBuffer[0] ;
if (accz <=31)
ret.Z = accz/2.17;
else
ret.Z = (accz - 64) * 0.47;
double somefactor = 1; return ret.Scale(somefactor);
}
Note that the when called with AccReadValues parameter, the DeviceIoControl returns three bytes each of them containing a signed 6 bit 2's complement value.Basicly there are values on 6 bit ranging from -32 to +31. In the docs below there are tables that put in correspondence these values with acceleration in range -1.5g +1.5g which are the limits of the device. The code I wrote returns acceleration in meters/second2 where 1g=9.8 m/s2. That information I extracted from the technical specifications of the MMA7660FC accelerometer, as found at(try a google search). Also, the type of the accelerometer circuit is found in the service manual (I only found the service manual for LG GM730 which is pretty close).The same thing I also posted at codeplex.
All that means that you are in a good way to make the gm750 sensor act like samsung' s, even htc's, sensor???
Oh, iamspv, please make it work, I begging you!
jowl_tnt said:
All that means that you are in a good way to make the gm750 sensor act like samsung' s, even htc's, sensor???
Oh, iamspv, please make it work, I begging you!
Click to expand...
Click to collapse
It already works! There is nothing more to do about it than use the code in your applications (I speak as a programmer and for programmers). I only showed everyone interested in developing for LG GM750 the steps to modify the SamsungGSensor class from "Unified Sensor Api" at codeplex to work with a LG. Just get the rest of the code from there and put it toghether.
Now there are two directions:
Direction #1
If you want to develop applications that aim to be portable between HTC, Samsung, LG, Toshiba, etc, and you want to use Unified Sensor Api then..
the person responsible for the unified api project at codeplex should make the update to the library as soon as possible such way the library should keep compatibility with the adressed devices. I'm just contributing with some results. That's because the initial code was not very general (ie. the initial parameter types to deviceiocontrol invoked from coredll didn't work with this solution) I had to make some modifications to the code that work with the LG but affect other devices' sensor classes. Now, if the update doesn't come up soon, no problem, anyone just gets the code from codeplex, adds a new class for LG, copies code from Samsung, renames Samsung with LG, adds my modifications, corrects syntax errors, compiles, et voila . . the library is updated to support LG GM750.
Direction #2
If you develop only for LG, just write a LG class as presented above and don't care about other devices.
If you don't know how to use your new class, the project at codeplex has some examples and you'll easily see inside the code how to instantiate sensors, how to read data at certain moments using a timer, and how to capture screen rotation events.
And for your long awaited joy to see it working, I attached the sensor test program along with a version of sensors.dll compiled by me, that works for GM750.
Now get your fingers toghether on the keyboard and start developing for LG
Thanks a lot for this! I can now play sensory-overload on the LG750
I downloaded the game and replaced the sensor.dll with your version.
Now I'll need to find out how to use this with SPB Mobile Shell...
Thanks for your help but I'm not a programmer and I don't understand much of these.
I think the solution is to make a modified HTCSensorSDK.dll for gm750. Then all gsensor apps for htc will work on our lg. Is that right;
That is what so many users have been waiting for.
It works for LG GM735 as well.
much appreciated !. Well done!.
roolku said:
Thanks a lot for this! I can now play sensory-overload on the LG750
I downloaded the game and replaced the sensor.dll with your version.
Now I'll need to find out how to use this with SPB Mobile Shell...
Click to expand...
Click to collapse
roolku, please confirm that when playing sensory-overload the Y axis is reversed. It is an issue of the Sensor API I encountered while testing.
The theory says,
"The positive X axis is from the center of the screen to the right.
The positive Y axis is from the center of the screen to the top.
The positive Z axis is from the front of the screen towards the viewer."
but this isn't the case in sensor api.
I respected this theory when I returned the acceleration values, as you can see in my sensor test program. But also you will see the api considers Portrait as Reverse Portrait.
Developers should be aware of these issues and make the appropiate changes to the library when writing code.
iamspv said:
roolku, please confirm that when playing sensory-overload the Y axis is reversed. It is an issue of the Sensor API I encountered while testing.
Click to expand...
Click to collapse
Yes, you are right. I couldn't quite put my finger on what was strange when playing it.
iamspv said:
I respected this theory when I returned the acceleration values, as you can see in my sensor test program. But also you will see the api considers Portrait as Reverse Portrait.
Developers should be aware of these issues and make the appropiate changes to the library when writing code.
Click to expand...
Click to collapse
Hm, I wonder if it is more sensible to conform to the established convention rather than expect everybody else to change their ways. Unless I misunderstood you?
Would you mind supplying a version of sensor.dll that is compatible with the Samsung one (i.e. reversed y-axis)?
thank you, clublgmobile you thanks, expect that works with all applications
I don't understand how that works. How can i play RescoBubbles for example;
this is excellent news. now if we could just get the GW820 (expo,IQ) accelsensor.dll dissasembled we'd be cookin with gas
killerskincanoe said:
this is excellent news. now if we could just get the GW820 (expo,IQ) accelsensor.dll dissasembled we'd be cookin with gas
Click to expand...
Click to collapse
Yes, it would be very much appreciated! Ive been looking for a htc wrapper for our sensor since i got the phone.
I attached the accelsensor.dll from the eXpo in case that will help at all. I wish i had the knowledge to do more myself..
edit:
Also, theres a game that comes stock on At&t's model gw820 called Ferrari GT Evolution that uses the gsensor. Its made by gameloft so maybe its not as hard to get to as the incites?
to roolku:
Here is a modified version of sensors.dll with reversed Y axis that will a allow you to normally play sensory overload on your GM750. Using the GSensorTest you will see Portrait is now detected correctly.
Also, this version of sensors.dll works on HTC and Samsung as the original one , I managed to separate code. See the attachement.
to theyllib
I dissassembled the gw820 accelsensor.dll you provided. Looks like the interesting part is here
this is some data
Code:
.text:100027CC dword_100027CC DCD 0x32100C ; DATA XREF: ACC_IOControl+25Cr
.text:100027D0 dword_100027D0 DCD 0x321008 ; DATA XREF: ACC_IOControl+250r
.text:100027D4 dword_100027D4 DCD 0x321004 ; DATA XREF: ACC_IOControl:loc_1000263Cr
.text:100027D8 off_100027D8 DCD unk_10005650 ; DATA XREF: ACC_IOControl+8Cr
.text:100027D8 ; ACC_IOControl+138r ...
.text:100027DC dword_100027DC DCD 0x22200C ; DATA XREF: ACC_IOControl+80r
.text:100027E0 dword_100027E0 DCD 0x222008 ; DATA XREF: ACC_IOControl+74r
.text:100027E4 dword_100027E4 DCD 0x222004 ; DATA XREF: ACC_IOControl+68r
.text:100027E8 dword_100027E8 DCD 0x222010 ; DATA XREF: ACC_IOControl+48r
.text:100027EC off_100027EC DCD aAcc_iocontrol0 ; DATA XREF: ACC_IOControl+30r
.text:100027EC ; "ACC_IOControl(%08x)"
and this is where they are adressed
Code:
.text:10002440 LDR R3, =0x222010
.text:10002444 CMP R6, R3
.text:10002448 BHI loc_100025D4
.text:1000244C BEQ loc_10002588
.text:10002450 MOV R3, 0x222000
.text:10002458 CMP R6, R3
.text:1000245C BEQ loc_100025C0
.text:10002460 LDR R3, =0x222004
.text:10002464 CMP R6, R3
.text:10002468 BEQ loc_10002540
.text:1000246C LDR R3, =0x222008
.text:10002470 CMP R6, R3
.text:10002474 BEQ loc_10002518
.text:10002478 LDR R3, =0x22200C
.text:1000247C CMP R6, R3
.text:10002480 BNE loc_10002660
.text:10002484 LDR R3, =unk_10005650
.text:10002488 LDR R3, [R3]
.text:1000248C CMP R3, #1
.text:10002490 MOVNE R3, #0
The codes that must be sent to DeviceIoControl in coredll.dll are probably the 0x22200C, 0x222008 and stuff. The 0x321008 and stuff are some power get/set codes. But you need a programmer with an actual gw820 device to make it work as it need lots of testing. Hope this information helps and someone with such device will make it work.
Can anyone check if the Incite comes with ACCAPI.DLL, and if so can it be posted ?
I have existing Android code that submits a pre-constructed packet over UDP to a hardware device... however, I now need to convert this code to work over TCP instead in order to be more reliable. Currently the code will send the packet to the device, and wait for a predetermined Timeout time for the Device to "answer" back over the same UDP port and to the source IP. The hardware device listens on both UDP and TCP on the same port numbers.
The UDP code looks like this:
Code:
serverSocket = new DatagramSocket(ListenPort);
{
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddressOut);
serverSocket.send(sendPacket);
serverSocket.setSoTimeout(TimeOut);
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
byte[] tempDataBuf = Arrays.copyOfRange(receiveData, 0, receivePacket.getLength());
MsgReply.ApplyMessageData(tempDataBuf);
System.out.println("RECEIVED: " + MsgReply.toString());
publishProgress(MsgReply.toString().getBytes());
}
Can anyone assist me in converting this code into TCP format?
Appreciate any help!
PS...I asked this question on stackoverflow too, but got no response... heard XDA started a programming forum, so figured I'll give this a bash
Code:
try {
s=new Socket(InetAddress.getByName("192.168.0.2"),2020);
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
out= new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
//send output msg
String outMsg = "ok";
out.write(outMsg);
out.flush();
Log.i("TcpClient", "sent: " + outMsg);
//accept server response
String inMsg = null;
try {
inMsg = in.readLine() + System.getProperty("line.separator");
//Send ur data to the below method to do ur process
processdata(inMsg);
}
This my suggestion to use this code under the AsyncTask to support for further higher platform. if didnt done already..
Thank you very much... will give it a try shortly!
jacauc said:
Thank you very much... will give it a try shortly!
Click to expand...
Click to collapse
ok man, if u have problem with this code post it here and send PM.. Then only i can reach U immediately...
I'm particularly interested in how to convert these few particular lines of code to the UDP format..
The attached code sample is very close to what I came up with, but I'm not sure how to construct the packet and parse the results:
Code:
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddressOut);
and
Code:
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
and especially this line:
Code:
byte[] tempDataBuf = Arrays.copyOfRange(receiveData, 0, receivePacket.getLength());
Also...
What does this part do?:
Code:
System.getProperty("line.separator");
Any suggestions?
Thanks again
@jacauc
First of all if u are developing an Client application the following code will help U, For server coding its different its not Like UPD.
UDP probably need both server as all client socket to send and receive the data. But in case of TCP, its not necessary to have a Server Socket only client socket is enough for both read and write..
Code:
java.net.Socket s=new Socket(InetAddress.getByName(pre.getString("ip", "192.168.0.2")),2020);
Click to expand...
Click to collapse
This code create a client tcp socket and allow u to communication to the specific ip and port..
Code:
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddressOut);
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
Click to expand...
Click to collapse
these two lines will probably replaced by the above single line..
But if u for handling TCP socket U need two stream one for reading and other for write data to the stream.
Code:
java.io.InputStreamReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
java.io.OutputStreamWriter out= new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
Click to expand...
Click to collapse
The above two line probably help to construct Input and out Stream for u from that Socket.
byte[] tempDataBuf = Arrays.copyOfRange(receiveData, 0, receivePacket.getLength());
Click to expand...
Click to collapse
There is no necessary for this code here because u directly get the String of data from this stream
Code:
String inMsg = in.readLine()
;
Click to expand...
Click to collapse
This line will read the line of string from the stream.
System.getProperty("line.separator");
Click to expand...
Click to collapse
This line is not must. This line will add the system specific line sperator at the end of the string. Is used this in my application to find the line sperator to avoid some system related problem while finding the line end point..
@CoolMonster
Thanks again for your time... this is starting to make a lot of sense now!
I'm getting close!
One thing I had in the UDP code was to send a pre constructed byte to the Digi Wifi XBEE box i'm interfacing with. This is "senddata"
Now if I do
Code:
out.write(sendData);
I get an error message stating that out.write cannot handle a byte.
I have
Code:
private byte[] sendData = new byte[1024];
Does this mean that I should send my data in a string format instead of byte?
@CoolMonster
More information after some additional research:
Prior to sending my string to the hardware module, I need to send some packets to open the communication channel.
For the UDP packet, this is assembled as follows in Hex:
Command ID: 0x02
Command Options: 0
Frame ID: 0x01
Config Options: 0x02
AT Command: 49 53 (This is the HEX for the AT command I want to send, which translates to "IS" in ascii)
Thus, the packet looks like this in Hex:
02 00 01 02 49 53
Then I will get a Hex result which I am already parsing to make sense of the output.
@jacauc
http://stackoverflow.com/a/2879077/1405008
Click to expand...
Click to collapse
hai man check this link for handling byte array in tcp connection...
Let me know if u face problem in handling the above solution..
But I am sure about the Interface what u are using. U better test it by creating simple local server and test the code then test it with the real system..
Appreciate all your help with this! Seems to be working like I wanted it to now.
Thanks
jacauc said:
Appreciate all your help with this! Seems to be working like I wanted it to now.
Thanks
Click to expand...
Click to collapse
Cool, Ur welcome man...
Hi guys,
I'm trying to connect Lumia 920 to the Linux (actually, to the RaspBian Linux, running on the Raspberry Pi).
I've correctly installed bluetooth on RPi and successfully paired RPi with Lumia. I've took sources of the simple RFCOMM server (actualy, I don't need more - just some simple text exchange) from http://people.csail.mit.edu/albert/bluez-intro/
For WP8 I've used (slight modified) sources from http://developer.nokia.com/Communit...nces_via_Bluetooth_and_NFC_on_Windows_Phone_8
On the client (WP8) side, the function await socket.ConnectAsync(rpiHostName,"1"); working correctly and returns no error (and RPi status in the bluetooth settings is "Connected"). Also, I can send strings (bytes) to the socket without errors. But on the server side (http://people.csail.mit.edu/albert/bluez-intro/x502.html#rfcomm-server.c), execution get stuck at:
Code:
// accept one connection
client = accept(s, (struct sockaddr *)&rem_addr, &opt);
Do you have any ideas/working samples?
Thanks!
I'd make some examples if I had a Raspberry Pi. This is pretty awesome that you're able to do this... Imagine the possibilities.
snickler, the RPi is really cheap; it costs just $40 from Amazon with free shipping. And device is ready to go: you just need a sd-card, and any cell phone power adaptor, that's all!
You may plug an USB hub, WiFi/BT dongles, keyboard, mouse or a webcam. Or connect it to TV by HDMI cable and use as media player (it can drive full HD video).
He-he, and it's open source; no (stupid) restrictions as on WP
P.S. I'm trying to build a small home robot to entertain my little princess (no, I'm lying actually: I entertain myself in the first place ).
Well, if you posted more code, I'm sure we could help you. However, it's pretty hard to do so when we have no idea how it works .
Sunius1 said:
Well, if you posted more code, I'm sure we could help you. However, it's pretty hard to do so when we have no idea how it works .
Click to expand...
Click to collapse
Sure, of course! https://www.dropbox.com/s/4fyp7nxgvlgkamb/bt.zip
Linux folder contains very simple linux socket server. IP part is working fine but not a BT. You may comment all RPi related stuff (currently I'm awaiting for the motor shield so the wiringPi commands just turn switching light diodes connected to GPIO ) and run server on the regular Linux box.
WP8 folder contains simple WP8 app (also working via IP or BT). IP part is working just fine (currently no advanced error handling implemented but it's OK for proto) but I can't communicate with Linux via BT
I've checked the code. Everything looks fine except the bind part on the server:
Code:
bind_return = ::bind ( m_sock, ( struct sockaddr * ) &m_addrBt, sizeof ( [b]m_addrIp[/b] ) );
Also, I couldn't find the documentation for it, so I'm not sure you're using bdaddr_t correctly.
Other than that, make sure nothing is listening to that port on the RaspberryPi - since the phone reports it connected successfully - it might have connected to some other application.
Yes, you right. It's mistyping, my fault (the sizes are different). Thanks! Can't try now, still working at office...
Sunius1, could you try this code on Linux (with correction)? And could you share yours (correct, I hope so ) /etc/bluetooth/* configuration files (I mean, what I should have in /etc/bluetooth/ to get this code working). I'm not a "Linux guy" unfortunately...
BTW, could you please provide any (even very simple) code to communicate between WP8 and Linux via Bluetooth (RFCOMM, L2CAP, etc.)?
Tried with code correction (proper structure size); unfortunately it doesn't helps MS tutorials are full of "how to connect windows phone to windows phone". Can't find anything about WP and Linux
Yeees! I've solved it!
The issue is solved by choosing port 5! I've run the sdptool on the RPi (output bellow) and discover that channels 1-4 are used by the damn WP... And (that is ridiculous!) nobody (yeah, that's right - MSFT's, damn "experts") at the MS or Nokia's forums never mentioned that!
So, I've changed the RF channel from "1" (this - damn f&*%ng lammahs! - mentioned at all (but very rare!) examples) to "5" and get strong and reliable connection!
Anybody, feel free to use posted (above, a few posts up) code; probably later I'll post whole projects (for WP & RPi Linux) on codeplex or github.
Code:
[email protected] ~/hobo/socket $ sdptool browse 54:79:75:C9:13:FA
Browsing 54:79:75:C9:13:FA ...
Service Name: Service Discovery
Service Description: Publishes services to remote devices
Service Provider: Microsoft
Service RecHandle: 0x0
Service Class ID List:
"SDP Server" (0x1000)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 1
"SDP" (0x0001)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Service Name: Device ID Service Record
Service Description: Device ID Service Record
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 1
"SDP" (0x0001)
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Service Name: Object Push Profile
Service RecHandle: 0x10001
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100
Service Name: Microsoft Windows Audio Source
Service RecHandle: 0x10002
Service Class ID List:
"Audio Source" (0x110a)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 25
"AVDTP" (0x0019)
uint16: 0x102
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Advanced Audio" (0x110d)
Version: 0x0102
Service Name: Voice Gateway
Service RecHandle: 0x10003
Service Class ID List:
"Handsfree Audio Gateway" (0x111f)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0105
Service Name: Phone Book Access PSE
Service RecHandle: 0x10004
Service Class ID List:
"Phonebook Access - PSE" (0x112f)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
"OBEX" (0x0008)
Profile Descriptor List:
"Phonebook Access" (0x1130)
Version: 0x0101
Service Name: BtSoftAp Service
Service RecHandle: 0x10005
Service Class ID List:
UUID 128: 232e51d8-91ff-4c24-ac0f-9ee055da30a5
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 4
Profile Descriptor List:
"" (0x232e51d8-91ff-4c24-ac0f-9ee055da30a5)
Version: 0x0100
Service Name: Audio Video Remote Control Profile
Service RecHandle: 0x10006
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x103
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0104
Awesome! Glad you've solved it. I'm not running linux so I can't share those files, unfortunately. I just looked at the code from Windows .
Thanks, man! There are a few more small issues (4 example, when you trying to reconnect to the already connected device, the ConnectAsync method fails - looks like a MS "experts" never tested that issue - and, AFAIK there is no API to solve it ) but it's OK I've got my motor shield today and the next big task is to let my little "guy" to move free in the house
Did you look at Winsock API? It's huge, it can achieve much more things than you can do through regular C# sockets. AND it's wholly available on Windows Phone 8.
Thanks for suggestion but my current solution with StreamSocket (yes, I know it lacks a lot of features) satisfy my needs on 99.9%
I don't need something more sophisticated: my goal is to use WP as a "robot remote control", to manually controlling the chassis and choose and run HoBo's programs (coming soon).