[Q] WinJS upload to PHP Server - Windows 8 Development and Hacking

Hi everybody
I need some help with uploading a File from a Javascript / HTML App to a PHP Server using WinJS. Everything looks good, the Server gives me a "200 OK" answer, but no File was saved on the Server. The upload application is built on the sample from MS. (https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61#content)
I dont know why the file wont be stored on the Server. Im started with a simple PHP-Script on the Serverside:
PHP:
<?php
$uploaddir = '/home/app/uploads/';
$uploadfile = $uploaddir . basename($_FILES['Filename']['name']);
move_uploaded_file($_FILES['Filename']['tmp_name'], $uploadfile);
?>
Sorry for my bad english!
Can somebody help me out of my problem?

It doesn't look like the WinJS example provided at that link actually uploads a file using the same mechanism as a form upload - rather, the file body is directly posted.
It looks like it sends a request similar to:
POST /upload.aspx HTTP/1.1
Filename: [the name of your file]
Content-Type: [whatever type]
Content-Length: [however long]
...
In PHP, to handle that:
PHP:
<?php
if (isset($_SERVER['HTTP_FILENAME'])) {
$name = $_SERVER['HTTP_FILENAME'];
$uploaddir = '/home/app/uploads/';
$uploadfile = $uploaddir . basename($name);
$input = fopen('php://input', 'r');
$output = fopen($uploadfile, 'w');
stream_copy_to_stream($input, $output);
}
andy123456 said:
Hi everybody
I need some help with uploading a File from a Javascript / HTML App to a PHP Server using WinJS. Everything looks good, the Server gives me a "200 OK" answer, but no File was saved on the Server. The upload application is built on the sample from MS. (https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61#content)
I dont know why the file wont be stored on the Server. Im started with a simple PHP-Script on the Serverside:
PHP:
<?php
$uploaddir = '/home/app/uploads/';
$uploadfile = $uploaddir . basename($_FILES['Filename']['name']);
move_uploaded_file($_FILES['Filename']['tmp_name'], $uploadfile);
?>
Sorry for my bad english!
Can somebody help me out of my problem?
Click to expand...
Click to collapse

I have searched so long for this, and now it works, tank you very much!
Does this mean, that the MS upload sample doesnt send the "Filename" in the headers? Does the Code
PHP:
$_SERVER['HTTP_FILENAME'];
means, that every headername will be accepted from the PHP Script?
Edit// Ok i understand it now, this is the headers name.
One more little problem i have. I need also the ability to upload multiple files. Now i have edited the PHP Script, with a foreach loop to handle that. But it seems that the MS Multiupload sample does send the files in another way, as i want to receive them in the PHP Script. I have done the following:
PHP:
<?php
if (count($_SERVER['HTTP_FILENAME'])) {
foreach ($_SERVER['HTTP_FILENAME'] as $file) {
$uploaddir = '/home/app/uploads/';
$uploadfile = $uploaddir . basename($file);
$input = fopen('php://input', 'r');
$output = fopen($uploadfile, 'w');
stream_copy_to_stream($input, $output);
}
}
?>

andy123456 said:
One more little problem i have. I need also the ability to upload multiple files. Now i have edited the PHP Script, with a foreach loop to handle that. But it seems that the MS Multiupload sample does send the files in another way, as i want to receive them in the PHP Script. I have done the following:
Click to expand...
Click to collapse
For the multiple file upload case, it looks like it performs the same thing as a typical form post based on the upload handler. Handling that should mostly be a case of determining what gets stuck into PHP's $_FILES array.

irony_delerium said:
For the multiple file upload case, it looks like it performs the same thing as a typical form post based on the upload handler. Handling that should mostly be a case of determining what gets stuck into PHP's $_FILES array.
Click to expand...
Click to collapse
I have tested this, but it doesnt ssem to work. There is everytime an error in the webservers logfile:
Code:
PHP Notice: Undefined index: File in...
But when i look at the exampe Code, i see the name of the index is named "File", or do i understand this wrong?

I don't know what the name being posted happens to be.
Try doing:
PHP:
error_log(print_r($_FILES, true));
And see what comes out in the error log.

irony_delerium said:
I don't know what the name being posted happens to be.
Try doing:
PHP:
error_log(print_r($_FILES, true));
And see what comes out in the error log.
Click to expand...
Click to collapse
Ok i have done that and i see now the problem, but i dont know what to do. I cleaned up the error log for a better view, so here is the error.log output:
Code:
[Mon Oct 13 17:51:44 2014] [error] [client 192.168.1.10] Array\n(\n [File0] => Array\n (\n [name] => test1.png\n [type] => \n [tmp_name] => /tmp/phpSyP9u2\n [error] => 0\n [size] => 6827\n )\n\n [File1] => Array\n (\n [name] => test2.png\n [type] => \n [tmp_name] => /tmp/php1jaQ0u\n [error] => 0\n [size] => 6827\n )\n\n [File2] => Array\n (\n [name] => test3.png\n [type] => \n [tmp_name] => /tmp/phpGHBxwX\n [error] => 0\n [size] => 6827\n )\n\n)\n
[Mon Oct 13 17:51:44 2014] [error] [client 192.168.1.10] PHP Notice: Undefined index: File in /home/app/multiupload.php on line 4
[Mon Oct 13 17:51:44 2014] [error] [client 192.168.1.10] PHP Notice: Undefined index: File in /home/app/multiupload.php on line 5
The problem is, that i can set only one index in the PHP-Script, in my example "File" -> $_FILES['File']['name']. Now i checked the code from the uploader app in the MS example:
Code:
BackgroundTransferContentPart part = new BackgroundTransferContentPart("File" + i, files[i].Name);
This is the reason, why the index from the client(app) is named "File0", "File1", "File2". Now when i remove the "+i - counter", all uploaded Files will have only "File" as index, but then only the first one shall was uploaded.

andy123456 said:
The problem is, that i can set only one index in the PHP-Script, in my example "File" -> $_FILES['File']['name']. Now i checked the code from the uploader app in the MS example:
Code:
BackgroundTransferContentPart part = new BackgroundTransferContentPart("File" + i, files[i].Name);
This is the reason, why the index from the client(app) is named "File0", "File1", "File2". Now when i remove the "+i - counter", all uploaded Files will have only "File" as index, but then only the first one shall was uploaded.
Click to expand...
Click to collapse
Try using "File[]" as the name instead - when sending form data to PHP, if you want to have multiple fields with the same name, they need to have an array-like name; otherwise, PHP overwrites the data with the last submitted value. The thing to note here is that PHP has slightly odd handling of that case - your file upload data will be structured as:
PHP:
$_FILES = [
'File' => [
'name' => [
0 => 'test1.png',
1 => 'test2.png',
2 => 'test3.png'
],
'tmp_name' => [ /* upload paths */ ],
'type' => [ /* file types */ ],
'size' => [ /* file sizes */ ],
'error' => [ /* upload errors for each item */ ]
]
];

irony_delerium said:
Try using "File[]" as the name instead - when sending form data to PHP, if you want to have multiple fields with the same name, they need to have an array-like name; otherwise, PHP overwrites the data with the last submitted value. The thing to note here is that PHP has slightly odd handling of that case - your file upload data will be structured as:
PHP:
$_FILES = [
'File' => [
'name' => [
0 => 'test1.png',
1 => 'test2.png',
2 => 'test3.png'
],
'tmp_name' => [ /* upload paths */ ],
'type' => [ /* file types */ ],
'size' => [ /* file sizes */ ],
'error' => [ /* upload errors for each item */ ]
]
];
Click to expand...
Click to collapse
Do you mean i should change the "name" in the BackgroundUploader?

Yes, in your code example above, change:
"File" + I
To:
"File[]"

Yes, it works! As you said, i changed the "name" in the BackgroundUploader, it looks as follows now:
Code:
BackgroundTransferContentPart part = new BackgroundTransferContentPart("[B]File[][/B]", files[i].Name);
My PHP-Script looks now:
PHP:
<?php
error_log(print_r($_FILES, true));
foreach ($_FILES['File']['name'] as $key=>$file) {
$uploaddir = '/home/HoPic/uploads/';
$target = $uploaddir.$file;
move_uploaded_file($_FILES['File']['tmp_name'][$key], $target);
}
?>
The error log gives me the following output:
Code:
[Mon Oct 13 19:32:11 2014] [error] [client 192.168.1.10] Array\n(\n [File] => Array\n (\n [name] => Array\n (\n [0] => test1.png\n [1] => test2.png\n [2] => test3.png\n )\n\n [type] => Array\n (\n [0] => \n [1] => \n [2] => \n )\n\n [tmp_name] => Array\n (\n [0] => /tmp/phpTJb14w\n [1] => /tmp/phplhgpAV\n [2] => /tmp/phpX5cW5j\n )\n\n [error] => Array\n (\n [0] => 0\n [1] => 0\n [2] => 0\n )\n\n [size] => Array\n (\n [0] => 6827\n [1] => 6827\n [2] => 6827\n )\n\n )\n\n)\n
I think everthing is ok now?

Related

[Q] WP7 - Removing an XElement from an XML file

Hi there,
I'm having a big issue, when trying to remove an XElement from an XML file created in IsolatedStorage.
--------------------------------------------------------------------------------------------
Code to CREATE the XML file
Dim File_to_Create As String = "Tracks.xml"
Dim file As XDocument = <?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlnsd="urn:schemas-microsoft-comfficedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Cartridges.xsd" generated="2010-11-23T14:26:55">
<Carts>
<CART_NAME>First</CART_NAME>
<CART_COLOR>White</CART_COLOR>
</Carts>
<Carts>
<CART_NAME>Second</CART_NAME>
<CART_COLOR>Black</CART_COLOR>
</Carts>
</dataroot>
Dim isoStore As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Try
If isoStore.FileExists(File_to_Create) Then
MessageBox.Show(File_to_Create + " TRUE")
Else
MessageBox.Show(File_to_Create + " FALSE")
Dim oStream As New IsolatedStorageFileStream(File_to_Create, FileMode.Create, isoStore)
Dim writer As New StreamWriter(oStream)
writer.WriteLine(file)
writer.Close()
MessageBox.Show("OK")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
'open selected file
Dim isoStream As IsolatedStorageFileStream
isoStream = New IsolatedStorageFileStream(File_to_Create, System.IO.FileMode.Open, System.IO.FileAccess.Read, isoStore)
Dim XML_File As XDocument = XDocument.Load(isoStream)
Dim Cart_Query As System.Collections.IEnumerable = From query In XML_File.Descendants("Carts") Order By _
CStr(query.Element("CART_NAME")) Descending, CStr(query.Element("CART_NAME"))
Select New Class_Cartridge_Data With {.Cart_Name = CStr(query.Element("CART_NAME")), _
.Cart_Color = CStr(query.Element("CART_COLOR"))}
Me.ListBox_Cartridges.ItemsSource = Cart_Query
isoStore.Dispose()
isoStream.Close()
End Try
--------------------------------------------------------------------------------------------
Code to ADD / EDIT XElement
Dim File_to_Create As String = "Tracks.xml"
Dim XML_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()
' Check that the file exists if not create it
If Not (XML_IsolatedStorage.FileExists(File_to_Create)) Then
Return
End If
Dim XML_StreamReader As New StreamReader(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Read))
Dim XML_Document As XDocument = XDocument.Parse(XML_StreamReader.ReadToEnd())
XML_StreamReader.Close()
' Update the element if it exist or create it if it doesn't
Dim XML_XElement As XElement = XML_Document.Descendants("Carts").Where(Function(c) c.Element("CART_NAME").Value.Equals("First")).FirstOrDefault()
If XML_XElement IsNot Nothing Then
XML_XElement.SetElementValue("CART_NAME", "Third")
Else
' Add new
Dim newProgress As New XElement("Cartridges", New XElement("CART_NAME", "Fourth"), New XElement("CART_COLOR", "Blue"))
Dim rootNode As XElement = XML_Document.Root
rootNode.Add(newProgress)
End If
Using XML_StreamWriter As New StreamWriter(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Write))
XML_StreamWriter.Write(XML_Document.ToString())
XML_StreamWriter.Close()
End Using
--------------------------------------------------------------------------------------------
Now my issue and request for some help!
If I use
XML_XElement.Remove
then the following exception is raised whenever I try to "refresh" the bounded ListBox
System.Xml.XmlException was unhandled
LineNumber=37
LinePosition=12
Message=Data at the root level is invalid. Line 37, position 12.
SourceUri=""
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream)
at ListBox_Data_from_XML_LINQ.MainPage.Button_Create_XML_Click(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
InnerException:
--------------------------------------------------------------------------------------------
In short, I can add or edit, but cannot DELETE an XElement...
Any ideas?
Thanks in advance!
Can you post the code you are using for XElement.Remove and use code tags so the formatting is right. Its the # button on the post toolbar.
Ren13B said:
Can you post the code you are using for XElement.Remove and use code tags so the formatting is right. Its the # button on the post toolbar.
Click to expand...
Click to collapse
Well, I did nothing special, just the XML_Element.remove, instead of adding a new xelement.
Then the error raises whenever I try to reopen the XML file.
My point is, how can I delete an specific xelement?
As far as I know, the following code should work
Code:
Dim XML_XElement As XElement = XML_Document.Descendants("Carts").Where(Function(c ) c.Element("CART_NAME").Value.Equals("First")).Firs tOrDefault()
If XML_XElement IsNot Nothing Then
XML_XElement.SetElementValue("CART_NAME", "Third")
Else
' remove the selected record
XML_XElement.Remove
End If
Honestly I don't know if the foregoing code is correct or if the issue is related to how WP7 handles the removal thus corrupting the original file.
Please let me know if you need anything else.
Any help is very appreciated!
PS: Thanks for the other replies, helped a lot!
Here's how I did it in c#. My xml file is very different than yours so the query will be different but the important parts are where you load and close the file streams and then write.
Code:
//Get users private store info
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream isoStream;
//open selected file
isoStream = new IsolatedStorageFileStream(list, System.IO.FileMode.Open, System.IO.FileAccess.Read, isoStore);
XDocument xml = XDocument.Load(isoStream);
isoStream.Close();
//Find section
XElement sectionElement = xml.Descendants("section").Where(c => c.Attribute("name").Value.Equals(groupn)).FirstOrDefault();
//Find item and remove it
sectionElement.Elements("setting").Where(c => c.Attribute("name").Value.Equals(litem)).FirstOrDefault().Remove();
isoStream.Close(); //Seems unnecessary but it's needed.
//Write xml file
isoStream = new IsolatedStorageFileStream(list, FileMode.Create, FileAccess.Write, isoStore);
xml.Save(isoStream);
isoStream.Close();
Thanks again for your help, greatly appreciated.
However I'm still getting the same error.
Sorry for asking, but are you getting any errors when deleting in WP7 ?
My knowledge on XML is extremely new and I'm sure that I'm making some mistakes somewhere...
But so far, I cannot get past the same exception.
Seems that the XML gots "corrupted" after the delete operation.
On the other hand, if is not too much to ask for, using my current code, how will handle the delete of the selected record?
Thanks!
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Ren13B said:
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Click to expand...
Click to collapse
Problem is my country is not listed so I cannot register...
Here is the C# version of my current code for adding/editing
Code:
public static void ADD_XML_Record()
{
string File_to_Create = "Tracks.xml";
var XML_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
// Check that the file exists if not create it
if (! (XML_IsolatedStorage.FileExists(File_to_Create)))
{
return;
}
StreamReader XML_StreamReader = new StreamReader(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Read));
XDocument XML_Document = XDocument.Parse(XML_StreamReader.ReadToEnd());
XML_StreamReader.Close();
// Update the element if it exist or create it if it doesn't
XElement XML_XElement = XML_Document.Descendants("Carts").Where((c) => c.Element["CART_NAME"].Value.Equals("dd")).FirstOrDefault();
if (XML_XElement != null)
{
XML_XElement.SetElementValue("CART_NAME", "bbbbb");
}
else
{
// Add new
XElement newProgress = new XElement("Carts", new XElement("CART_NAME", "dd"), new XElement("CART_COLOR", "ff"));
XElement rootNode = XML_Document.Root;
rootNode.Add(newProgress);
}
using (StreamWriter XML_StreamWriter = new StreamWriter(XML_IsolatedStorage.OpenFile(File_to_Create, FileMode.Open, FileAccess.Write)))
{
XML_StreamWriter.Write(XML_Document.ToString());
XML_StreamWriter.Close();
}
}
I tried your code but I'm having a bad time making it to work.
If not a big deal, please could you tell me how to modify it ?
I mean, if a record is found, instead of editing, to remove it?
Honestly I'm stuck and any help is more than apprecisted!
Ren13B said:
I have no problem at all removing elements in c#. I don't have vb support even installed right now. If you think it's a bug you should post on the forums at http://forums.create.msdn.com/forums/98.aspx
Click to expand...
Click to collapse
Ren,
Just to say thank you for your last code. I made a little mod and now it works ok!
Thanks a lot for helping me out!

Tools for Logging processes, like WinComm, Portmon, QXDM...

Nice and easy Tool:
http://www.softsea.com/review/Portmon.html
Maybe someone saw/know the yellow Message "UPLOAD data to pc"...
How to catch Data if "Bluescreen" comes and "UPLOAD data to pc" message appears?
It seems this nuke my Portmon...
Any suggestions please?
Maybe I'm blind or these are not stored in Debug folder...
Best Regards
Edit 1.
Changed title.
If you have a Windows XP machine left, try this to watch the serial port:
ups, i can't post links here. Google for serialmon dot com .....
It's output is a little easier to use than portmons. In general, using a serial port monitor to watch the communication between wave and pc, seems to be very unstable business.
Now I'm closer...
Taken info from Samsung GT-S8500L Wave Training Manual SW.ppt...
If someone needs the Settings to attach handset correct, ask me... in this Thread.
Best Regards
Could you post the settings, found this earlier, but couldn't do anything with it.
Thanks
I'll try to describe "short" steps.
1.
You have to be sure that Debug Level Middle is on. Please read here:
http://forum.xda-developers.com/showpost.php?p=10616930&postcount=3
Level Mode High shows more events...
2.
If you have access to Internal menu:
*#7092463*#
Maybe set to High or go to Debug Settings... described in ...Manual SW.ppt...
site 15
3.
Start WinComm and now check site 16 on *.ppt manual. All settings are on Picture.
4.
On handset I have choose Debug Mode instead Kies... this thingie if you plug cable into Wave... maybe go to Settings and set to ask by connection instead Kies
5.
Be sure you choose the "second" Port. Now Wave have 2 COM Ports activated.
Second one is for incoming Data.
Hope this helps an little bit.
If problems ask again.
Then I'll try to make some Screenshots or maybe some other hints...
Best Regards
Ehm have you found that Wincomm2010.exe
Click to expand...
Click to collapse
2010 no, but 2009 like in this Picture is attached.
WinComm2009.zip
Best Regards
Handset
Under Settings->Connectivity->USB->Ask on connection
To have chance to set USB Debugging
Wincomm
I will try later maybe Open or Close for connect to the port.
Important is to choose second COM Port...
Also important to activate UE Awake in settings like on Picture.
As it seems initial AT command is mandatory AT+WINCOMM...
Best Regards
P.S.:
I'm using XP 32 Bit... no other OS tested by me.
so now you can upload fw files from the phone or what???
so now you can upload fw files from the phone or what???
Click to expand...
Click to collapse
Now you could see internal process like Key press, which files involved... etc...
Many high technical stuff. But this could help to understand more.
For me it is very usefull.
I will soon attach few Log examples... maybe then more clear.
Best Regards
i don't suppose that anything can be done if *#7092463*#
doesn't get me a menu?
http://forum.xda-developers.com/showpost.php?p=12798896&postcount=5
Please read deeper this post and follow Links.
As Internal menu is disabled if you flashed ever Rsrc2_S8500_xxx(Low).rc2
Or if you not use Multiloader, then Kies did for you.
This is internal stuff, you have to "unlock" few things before... so read my instruction prior posted.
Please. This is more for advanced users. This is NO must have for all users.
At your own risk.
Best Regards
It seems also good idea to set Trace Level to High... in Internal Menu.
Best Regards
Edit 1:
Seems difference between Firmwareversions...
On JE7 I can see logging if handset is "off" if battery charge Animation is on.
Then if you press ON you can see parts of Booting sequence...
On JL2 I see first something, if Wave is fully on...
Maybe in higher Build some things disabled/removed...
Code:
3539 2255.054 [B]KEY_EVENT_SIG[/B]: [B]Keycode[/B] = 0x8f, STATUS = 0x0.
3540 2255.054 [LCD C]: INFO - FIMD_Drv_Resume()
3541 2255.054 S6E63M0 : LDI_Pentile_Set_Change Pentile_Value =6c
3542 2255.054 S6E63M0 : LDI_PortInit +
6217 2255.055 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0014 2263.372 -1: BOOTMGR > _BmPacketReceiveCallback: Boot command is [0x6]
6218 2255.055 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0015 2263.372 -1: EXCEPTION > OemTapiNetworkRadioInfoInd: RSSI refresh as AP's awaken
6219 2255.056 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0016 2263.372 -1: EXCEPTION > OemTapiNetworkCellInfoInd: Refresh cell Info as AP's awaken
6220 2255.063 P00.T10.D103.G22.E054:B25B EXCEPTION > SmsSvcRegGetSellOutToBeSent: bToBeSent = [0].
6221 2255.069 P00.T10.D103.G22.E054:B269 EXCEPTION > SmsTapiEventHandler: unknown tapi event type.
[B]3543 2255.085 S6E63M0 : LDI_PortInit -
3544 2255.085 S6E63M0 : LDI_S6E63M0_Power_On +
3545 2255.095 S6E63M0 : LDI_S6E63M0_Power_On [hwrev > [COLOR="Red"]S8200[/COLOR]_UNIV_B7]
3546 2255.095 S6E63M0 : LDI_Pentile_Set_Change Pentile_Value =6c
3547 2255.219 S6E63M0 : LDI_S6E63M0_Power_On -
3548 2255.219 Display_LSI : disp_Main_Wakeup [/B]
3549 2255.219 [TSP] reset acq atchcalst=0, atchcalsthr=0
3550 2255.220 [TSP] clear garbage data : Success!! [read 0 times]
3551 2255.220 [TSP] TSP Wakeup...........!
I was wondering why S8200... but now its more clear.
http://forum.xda-developers.com/showpost.php?p=12797112&postcount=249
What we can do...
Collect Key Events...
Monitoring processes like start JAVA Midlets...
Then we can see infos about Heap size...
Code:
9301 433.174 P00.T10.D094.G52.E103:2D83 EXCEPTION > KJxMemoryAvailable: [B]available memory heap[/B] size is 131268608
9302 433.178 P00.T10.D300.G52.E103:2D83 EXCEPTION > KJxSvcIsFileSystemValid: return TRUE!
9303 433.178 P00.T10.D300.G52.E103:2D83 EXCEPTION > KJavaGetMidletAttributeBySuiteID suiteID = 5 is not found
9304 433.179 P00.T10.D094.G52.E103:2D83 EXCEPTION > KJxSvcIsMemoryFull fmQuotaStat.availableSize(943128576), APP_MEMORY_STATUS_MX_MEMORY_FULL_LIMIT(0)
9305 433.180 P00.T10.D094.G52.E103:2D83 EXCEPTION > KJxSvcIsMemoryFull KJx execute limit size = 16384
9306 433.180 P00.T10.D300.G52.E103:2D83 EXCEPTION > KJxSvcIsFileSystemValid: return TRUE!
Many more things...
Best Regards
adfree said:
Code:
3539 2255.054 [B]KEY_EVENT_SIG[/B]: [B]Keycode[/B] = 0x8f, STATUS = 0x0.
3540 2255.054 [LCD C]: INFO - FIMD_Drv_Resume()
3541 2255.054 S6E63M0 : LDI_Pentile_Set_Change Pentile_Value =6c
3542 2255.054 S6E63M0 : LDI_PortInit +
6217 2255.055 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0014 2263.372 -1: BOOTMGR > _BmPacketReceiveCallback: Boot command is [0x6]
6218 2255.055 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0015 2263.372 -1: EXCEPTION > OemTapiNetworkRadioInfoInd: RSSI refresh as AP's awaken
6219 2255.056 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0016 2263.372 -1: EXCEPTION > OemTapiNetworkCellInfoInd: Refresh cell Info as AP's awaken
6220 2255.063 P00.T10.D103.G22.E054:B25B EXCEPTION > SmsSvcRegGetSellOutToBeSent: bToBeSent = [0].
6221 2255.069 P00.T10.D103.G22.E054:B269 EXCEPTION > SmsTapiEventHandler: unknown tapi event type.
[B]3543 2255.085 S6E63M0 : LDI_PortInit -
3544 2255.085 S6E63M0 : LDI_S6E63M0_Power_On +
3545 2255.095 S6E63M0 : LDI_S6E63M0_Power_On [hwrev > [COLOR="Red"]S8200[/COLOR]_UNIV_B7]
3546 2255.095 S6E63M0 : LDI_Pentile_Set_Change Pentile_Value =6c
3547 2255.219 S6E63M0 : LDI_S6E63M0_Power_On -
3548 2255.219 Display_LSI : disp_Main_Wakeup [/B]
3549 2255.219 [TSP] reset acq atchcalst=0, atchcalsthr=0
3550 2255.220 [TSP] clear garbage data : Success!! [read 0 times]
3551 2255.220 [TSP] TSP Wakeup...........!
I was wondering why S8200... but now its more clear.
http://forum.xda-developers.com/showpost.php?p=12797112&postcount=249
What we can do...
Collect Key Events...
Monitoring processes like start JAVA Midlets...
Then we can see infos about Heap size...
Code:
9301 433.174 P00.T10.D094.G52.E103:2D83 EXCEPTION > KJxMemoryAvailable: [B]available memory heap[/B] size is 131268608
9302 433.178 P00.T10.D300.G52.E103:2D83 EXCEPTION > KJxSvcIsFileSystemValid: return TRUE!
9303 433.178 P00.T10.D300.G52.E103:2D83 EXCEPTION > KJavaGetMidletAttributeBySuiteID suiteID = 5 is not found
9304 433.179 P00.T10.D094.G52.E103:2D83 EXCEPTION > KJxSvcIsMemoryFull fmQuotaStat.availableSize(943128576), APP_MEMORY_STATUS_MX_MEMORY_FULL_LIMIT(0)
9305 433.180 P00.T10.D094.G52.E103:2D83 EXCEPTION > KJxSvcIsMemoryFull KJx execute limit size = 16384
9306 433.180 P00.T10.D300.G52.E103:2D83 EXCEPTION > KJxSvcIsFileSystemValid: return TRUE!
Many more things...
Best Regards
Click to expand...
Click to collapse
Heap size can already be changed by accesing the jwc_properties.ini in the AppEx and the User>Exe folder.
astrotom said:
Heap size can already be changed by accesing the jwc_properties.ini in the AppEx and the User>Exe folder.
Click to expand...
Click to collapse
can you recommend a value for it??
give an example for the change??
thanks in advance
mylove90 said:
can you recommend a value for it??
give an example for the change??
thanks in advance
Click to expand...
Click to collapse
There are three jwc_properties.ini files. 1st one in Appex>SysDefault>Java>jwc_properties.ini, 2nd one in Exe>Java>jwc_properties.ini and 3rd one in SystemFS>User>Exe>Java>jwc_properties.ini. Use trix, TkFile explorer or Stune. Personally, I think the first ini file is fore the default java apps on the phone. I think the 2nd one is useless since I didnt see any java apps in that folder using stune. I think the 3rd file is for user installed java apps. I dont know since I am still in the process of modifying the whole bada firmware as far as possible and then I will later flash my phone with my custom firmware. Maybe you could help me tell which files are used for what? Ok, enough talk. Now here are settings for heap sizes that I used: (You can find heap settings at the end of each file)
## Limited MVM configuration
MAIN_MEMORY_CHUNK_SIZE = 82313216 # (78 * 1024 * 1024) + (500 * 1024), 78.5MB
JAVA_MAX_HEAP_SIZE = 65011712 # (62 * 1024 * 1024) + (0 * 1024), 62MB
JAVA_MIN_HEAP_SIZE = 10485760 # (10 * 1024 * 1024) + (0 * 1024), 10MB
MAX_ISOLATES = 4 # AMS Isolate + One application
The last setting, MAX_ISOLATES is the max number of java apps you can run simultaneously while paused. My setting allows 5 apps to run simultaneously. (Remember, Max_ISOLATES value should be one less than the desired value.) Earlier it wave could run only 3 apps.
I am surprised the Samsung provided low java heap sizes for such a good phone! Anyways enjoy!
Thanx astrotom
I'll try next days.
About WinComm... now I understand what this setting means...
I'll try to find combination to work with both, Qualcomm and WinComm.
To log also via QXDM...
Maybe BT is helpfull...
Best Regards
Uuupsi.
Not realized before. But now I have Modem Port connected with:
Upload data to pc
Hmm. But no idea how to catch Data now...
I've changed Port in WinComm...
Hmmmmmm, mabye 1 day in future.
Best Regards
I've played little bit with old SGH-U700...
It has also few similar things like Upload data to pc...
Via known code *#197328blabla... I can find Upload Funct.:
Enable Upload Funct
Disable Upload Funct
Enable Debug Mode in Low
If I try to enable... Can't enable as Dbg Lvl Low...
This U700 is damaged... (damn Touch keys)... maybe I can repair... maybe I can find out what Upload ... can do.
Best Regards
Edit.
I've set Debug Level to high, then also Enable Upload Funct is available...
But still no idea how to start Upload...
how to send AT commands to the phone? i have the first port of my phone as COM9 and the second one as COM10

Key press events and Screenshot(s)... via PC

Now we could try to catch Key Commands and more... with WinComm, see here:
http://forum.xda-developers.com/showthread.php?t=928170
First idea, collect Commands for Key pressing Commands like this:
Code:
OemKeyPressInd:pre[VK_HP_HOLD(s:0x495)] , now[VK_HP_HOLD(s:0x495)]
2811 0509.625 KEY_EVENT_SIG: Keycode = 0x53, STATUS = 0x0.
2812 0509.625 KEY_EVENT_SIG: Keycode = 0x8f, STATUS = 0x0.
I think we have only 7 Hardware Keys... so this should not take years.
Touchscreennavigation is little bit harder...
Second idea... Screencapture... if we find command to send to handset, then maybe possible to capture Video sequencies.
Attached short Logfile from Screenshot taking on S8500 JE7...
Best Regards
P.S.:
Also AT commands or Qualcomm commands exists also for such feature.
Yes. I saw this on QuB but also failed. Answer was something to patch Loader...
Also Key Simulator is in QuB...
Not work yet with S8500. But I think we should investigate in such things.
Because "Basic" features.
Long time ago for my other handsets I have all these Tools.
Video Capture Tool...
But NOT for S8500.
Time to change this.
Best Regards
P.S.:
Not sure AT+SUBLCD or something else with LCD is used by Kies... found via Portmon...
I've tried to log with WinComm to see more or better understnad AT commands.
4161 1018.432 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0022 1026.696 -1: EXCEPTION > __RbmCHGetUserMemory : do u need me? really? sure? huh?
Click to expand...
Click to collapse
This is shown if i try:
AT+USERMEM
About AT+SUBLCD or AT+SUBLCD? nothing... maybe wrong... maybe additional parameter needed.
Kies used this I thought... AT+LCDINFO=MAIN
Also AT+MAINLCD or AT+MAINLCD leads to nothing...
I think parameter missing...
Best Regards
Edit 1.
Maybe this is from Kies sniffed...
AT+GETDPIMG=0
WinComm shows also something...
Code:
1863 2691.134 OBEX_Report : 304[BPS], ratio=100, request=190, send=190
4414 2694.194 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0047 2702.537 -1: AGENT > __AgRbSendPacket: before send fifo, dataLen(7596), apiID(0x1000002f)
4415 2694.196 P00.T11.D001.G-1.E-01:0000 AGENT > __AgRbFifoCallback: Rcvd 7596 bytes(Type:268435503 Len:7580).
4416 2694.196 P00.T11.D001.G-1.E-01:0000 AGENT > __AgRbPacketReceiveCallback: packet id 0x1000002f
4417 2694.196 P00.T11.D001.G-1.E-01:0000 AGENT > __AgRbPacketReceiveCallback: Req Packet id is [1280], len is [11], cmd is [GetDpImg 0 ]
4418 2694.196 P00.T11.D001.G-1.E-01:0000 AGENT > *> cmd="GetDpImg 0 "
4419 2694.227 P00.T11.D001.G-1.E-01:0000 AGENT > __RbmCHSaveDisplayImg : Time to get Screen Buffer is [30ms]
4420 2694.227 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Size is 768000, TotalPage is 8, LastPageSize is 79872
4421 2694.228 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [0]
4422 2694.232 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [1]
4423 2694.234 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [2]
4424 2694.237 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [3]
4425 2694.239 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [4]
4426 2694.241 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [5]
4427 2694.244 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [6]
4428 2694.246 P00.T11.D001.G-1.E-01:0000 AGENT > __RBUSBWrite : Sending Packet Page is [7]
4429 2694.248 P00.T11.D001.G-1.E-01:0000 AGENT > __RbmCHSaveDisplayImg : Time to Write through USB is [21ms]
[COLOR="Red"]4430 2694.248 P00.T11.D001.G-1.E-01:0000 AGENT [/COLOR] > __RbmCHSaveDisplayImg: [B]Compressed Scrn Img Buf was sent to PC successfully[/B]
4431 2694.248 P00.T11.D001.G-1.E-01:0000 AGENT > __RbmCHSaveDisplayImg : Elapsed Time is [51ms]
4432 2694.248 P00.T11.D001.G-1.E-01:0000 AGENT > __RbmCHGetDisplayImg: GetDisplayImg Success. Return is 1
4433 2694.248 P00.T11.D001.G-1.E-01:0000 AGENT > *> return value = 1 (0x00000001)
4434 2694.248 P00.T11.D001.G-1.E-01:0000 AGENT > __AgRbPacketReceiveCallback: Res Packet result is [1], len is [7588], rsp buf is []
4435 2694.258 P00.T11.D001.G-1.E-01:0000 AGENT > __AgRbFifoCallback: Send 7604 bytes(Type:268435503 Len:7588).
4436 2694.258 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0048 2702.539 -1: AGENT > __AgRbSendPacket: write message, written data len(7596)
4437 2694.263 P00.T11.D001.G-1.E-01:0000 EXCEPTION > [CPLog]: Sub 0049 2702.606 -1: AGENT > __RbmCHReadDevConItemInfo:Success
Maybe this is our Power ON OFF Format... or QMG ...
I have problems to recieve full Data from handset...
Searching for working Tool with HEX...
AT+GETDPIMG=0
Yes, this is Screencapture... 0 seems for RAW, uncompressed...
You can use WinComm itself to catch the incoming Data... around 700 KB.
You can send AT commands also...
With other Tools I failed... maybe my fault.
I will try if I can use other compress settings...
Best Regards
Eagerly waiting for your developments! By the way that message in wincomm was funny!
waiting for you adfree to get out from all of this with something useful for ordinary users with little brain like me
@ Dokugogagoji
Very good Tool. Tested short on JE7 Firmware...
NOT your Tool, I mean before.
During my experiments I've noticed also Buffer overflow with 0... as I had problems to catch whole data. But your Tool is really great.
My Wishlist. If you have time. Please.
1.
"Video Capture"... maybe we could start with send command every 1 second?
Maybe every 2 seconds... I don't know how fast buffer can handle this...
2.
Maybe please set Standard folder for capture. Example:
c:\screencap...
Nice would be, we had access to Config XML or other Text file to edit this.
Thank you very much.
Best Regards
Thanx for fast progress.
After press stop, I see only waiting... nothing happens.
XP 32 Bit
But maybe my fault.
Maybe someone else can try and confirm.
Sometimes I'm not smart enough to manage task.
Best Regards
adfree said:
After press stop, I see only waiting...
Click to expand...
Click to collapse
I have the same WinXP SP3 32 bit
Another picture is reflected(mirrored). BMP is scanned from bottom to top
Yes! Works fine
1000 thanx. Yes success.
Other folder would be very nice...
C:\Dokumente und Einstellungen\topsecret\Desktop
Maybe something like set working Directory. Then add 2 folders:
...\PictureScreenshot
...\Videocapture
Or something similar.
My Desktop is full.
Thanx.
Best Regards
Strange. Not sure...
tested on JE7 and JL2. If I try to capture Video on Apps like Games or something like that.
No success.
JAVA Midlets yes...
Screencapture also possible.
So generally Command should work...
Any idea?
Best Regards
Edit 1.
Captured from JAVA Midlet...
Now the Question is also. How to get more Frames per second.
@ Dokugogagoji
How often is AT Command sent? Every second?
Thanx.
Hi Dokugogagoji,
i had stability problems with the serial port class in .NET Framework too when i started with WaveBackup, but it seems to be working quite good now. If you want, we could compare our codes and see what it needs for a good and fast connection ....
Patrick
Upgrading from .NET 2.0 to 3.5 seemed to help a little with stability for me. Funny enough, i never tried a other baudrate as 115200 so far ..... i see you're using a much higher value there .... will do some test with it.
Tested it with WaveBackup ... speed remains the same, wether you use my value or your value .... it's always round abound 120 Kb/s ....
Lock key
3602 0547.460 KEY_EVENT_SIG: Keycode = 0x8f, STATUS = 0x1.
3852 0741.977 KEY_EVENT_SIG: Keycode = 0x8f, STATUS = 0x1.
End call
4934 1102.926 KEY_EVENT_SIG: Keycode = 0x51, STATUS = 0x1.
6260 1597.151 KEY_EVENT_SIG: Keycode = 0x51, STATUS = 0x1.
Start call
6351 1646.721 KEY_EVENT_SIG: Keycode = 0x50, STATUS = 0x1.
6351 1646.721 KEY_EVENT_SIG: Keycode = 0x50, STATUS = 0x1.
Volume Up
7653 2056.734 KEY_EVENT_SIG: Keycode = 0x54, STATUS = 0x1.
7847 2160.000 KEY_EVENT_SIG: Keycode = 0x54, STATUS = 0x1.
Volume down
8096 2222.667 KEY_EVENT_SIG: Keycode = 0x55, STATUS = 0x1.
8200 2267.922 KEY_EVENT_SIG: Keycode = 0x55, STATUS = 0x1.
Menu
8424 2320.139 KEY_EVENT_SIG: Keycode = 0x53, STATUS = 0x1.
8593 2447.716 KEY_EVENT_SIG: Keycode = 0x53, STATUS = 0x1.
Camera mid
8636 2472.871 KEY_EVENT_SIG: Keycode = 0x8e, STATUS = 0x1.
8664 2508.513 KEY_EVENT_SIG: Keycode = 0x8e, STATUS = 0x1.
Camera full
8810 2563.697 KEY_PRESS_TIMER_SIG: Keycode = 0x8d, STATUS = 0x1.
0808 3689.790 KEY_EVENT_SIG: Keycode = 0x8d, STATUS = 0x1.
On release key
STATUS = 0x0
Click to expand...
Click to collapse
headset button
0491 8305.228 KEY_EVENT_SIG: Keycode = 0x8a, STATUS = 0x1.
Click to expand...
Click to collapse
Taken from here:
http://forum.xda-developers.com/showpost.php?p=18960187&postcount=1330
Thanx.
Maybe some day usefull...
Best Regards
SetText
Nice Command, you can send Text to handset...
For instance long Link from PC... into Dolfin/Browser or SMS.
Short tested.
Best Regards
1 way for Key Input are AT Commands...
Digits 0-9
Code:
AT+KEY=10
AT+KEY=1
AT+KEY=2
AT+KEY=3
.
.
AT+KEY=9
Call Button
Code:
AT+KEY=11
End Button
Code:
AT+KEY=12
#
Code:
AT+KEY=13
*
Code:
AT+KEY=14
Delete/back
Code:
AT+KEY=15
Best Regards
http://forum.xda-developers.com/showpost.php?p=21567479&postcount=1
I have totally forgotten this source...
My Wave 2 has broken glas... and I can't click on Display...
PC Tool for text input via AT Commands would be nice...
Perfect would be... Navigation via Mouse...
Best Regards
Need navigation on broken display...
WinComm Log
Code:
[TSP] ID = 2, State = 0x20, X = 309, Y = 375
[TSP] All Fingers released : Send touch_screen_release!
Later more...
Any ideas?
Best Regards

[Q] Coding in Error checking for VB.net CF app

Hello all, Sorry for the dumb question but i'm pretty new to VB.Net CF.
I'm working on a little program that exports settings from the registry and then writes to the SD card for XDA_UC to import when a new rom installed. I'm currently struggling with the error checking code. I want it to be able to tell if there was an issue updating an already existing file with new settings but i can't seem to find a way to do it. I have managed to get it to check the file was written but this only works the first time. After that it always reports a success if the file is present in the expected location.
I've pated what i have below. I appreciate all and any thoughts you may have.
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BTIdent_Click([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BTIdent.Click[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Setup The variables so we can have them ready to write the .reg file[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BTIdentity [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\WIDCOMM\BTConfig\General"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"DeviceName"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\BT_Ident.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Format and then write the reg file to disk[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Windows Registry Editor Version 5.00"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine()[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\WIDCOMM\BTConfig\General]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""DeviceName""="""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + BTIdentity.ToString + [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.Flush()[/SIZE]
[SIZE=2]sw.Close()[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'Check that the file wrote successfully (this needs work becuase it will always report "operation successful" once the file has been written once[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] File.Exists([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\XDA_UC\BT_Ident.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Operation Complete."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]MessageBox.Show([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Operation Failed."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]
You could use FileSystemInfo properties of the file to make sure it was actually updated.
Code:
Dim fsi As FileSystemInfo = New FileInfo("\Storage Card\XDA_UC\BT_Ident.reg")
This will reveal the FileSystemInfo properties of the file, as defined here:
http://msdn.microsoft.com/en-us/library/system.io.filesysteminfo_members(v=VS.71).aspx
LastWriteTime is the last time the file was written to. If it wasn't within the last few seconds then the update has failed.
I've got to a point in my project where i actually need to look at doing this so thanks for taking the time to post.
this i what i've come up with so far
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]File.Exists([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\XDA_UC\VolumeTest.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] fsi [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileSystemInfo = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FileInfo([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\Storage Card\XDA_UC\volumetest.reg"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] fsi.LastWriteTime = DateAndTime.Now [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]OpComplete()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]OpFailed()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End If[/COLOR][/SIZE][/COLOR][/SIZE]
It should work but i would like to say dateandtime.now +/- say 5 seconds and i'm having trouble figuring that part out.
Any ideas?
This should do the trick.....
Code:
Dim Seconds5 As New TimeSpan(0,0,5)
If File.Exists("\Storage Card\XDA_UC\VolumeTest.reg") Then
Dim fsi As FileSystemInfo = New FileInfo("\Storage Card\XDA_UC\volumetest.reg")
If (DateAndTime.Now - fsi.LastWriteTime) < Seconds5 Then
OpComplete()
Else
OpFailed()
End If
End If
Alternatively, drop line 1 and put it straight into the compare, as that what the compiler will do anyway, when you switch it to a 'Release' build.
Code:
If File.Exists("\Storage Card\XDA_UC\VolumeTest.reg") Then
Dim fsi As FileSystemInfo = New FileInfo("\Storage Card\XDA_UC\volumetest.reg")
If (DateAndTime.Now - fsi.LastWriteTime) < New TimeSpan(0,0,5) Then
OpComplete()
Else
OpFailed()
End If
End If
Cool, thanks. I really do appreciate you taking the time to help.

prevent POST-request from caching

Hi,
when I try to make a jquery ajax "Typeost" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked. Here some code snippets to ilustrate my attempts:
This is my Ajax POST request:
Code:
$.ajaxSetup({
headers: {
"X-Requested-With" : "XMLHttpRequest",
"Content-Type" : "application/atom+xml",
"cache-control" : "no-cache",
"DataServiceVersion" : "2.0",
"X-CSRF-Token" : header_xcsrf_token,
},
cache: false,
});
$.ajax({
type: 'POST',
url: url + new Date().getTime(),
data : data,
beforeSend : function(xhr) {
// crypto call before authentication
var bytes = Crypto.charenc.Binary.stringToBytes(user + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
//build request header
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, status, xhr) {
alert("data sent");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown + " " + jqXHR.status + " " + jqXHR.responseText);
}
});
I've also tried to avoid the AppCache with following code in JAVA onCreate Method:
HTML:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
super.appView.getSettings().setAppCacheEnabled(false);
super.loadUrl(Config.getStartUrl());
CookieManager.getInstance().setAcceptCookie(true);
// Set by <content src="index.html" /> in config.xml
//super.loadUrl("file:///android_asset/www/index.html");
}
every time the Ajax Post request is made, it is directed to cache, and I don't know how to prevent it.
Cris Vilares said:
Hi,
when I try to make a jquery ajax "Typeost" request, I get an 404 not found (from cache) error. I've tried several workarounds to fix this problem but it doesn't worked.
Click to expand...
Click to collapse
You're probably getting a 404 because you're appending the timestamp onto the url without any seperator. Try this...
Code:
$.ajax({
type: 'POST',
url: url + (url.search("?") == -1 ? "?" : "&") + new Date().getTime(),
data : data,
beforeSend : function(xhr) {
// crypto call before authentication
var bytes = Crypto.charenc.Binary.stringToBytes(user + ":" + password);
var base64 = Crypto.util.bytesToBase64(bytes);
//build request header
xhr.setRequestHeader("Authorization", "Basic " + base64);
},
success: function(data, status, xhr) {
alert("data sent");
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus + " " + errorThrown + " " + jqXHR.status + " " + jqXHR.responseText);
}
});
That will append either ?nnnnnnnn or &nnnnnnnn to the url, depending on whether it already has a ? in it.

Categories

Resources