got at <unknown> <0xffffffff> stacktrace error (see code below) - xamarin.ios

if (this.PendingLocalUARTCreditsCount != 0) return;
this.PendingLocalUARTCreditsCount = this.MaxLocalUARTCreditsCount - this.LocalUARTCreditsCount;
IntPtr value = (IntPtr)(this.PendingLocalUARTCreditsCount);
NSData valueData = NSData.FromBytes(value, 1);
this.CbPeripheral.WriteValue(valueData, this.UartRxCreditsCharacteristic, CBCharacteristicWriteType.WithoutResponse);
Got stacktrace error with NSData valueData = NSData.FromBytes(value, 1);

I haven't solved it though in any way. I am developing in C# for an ipad app project using vs 2019 and a, Mac
Nick

Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.
=================================================================

I got SIGSEGV error not SIGABRT. I can discover connect and disconnect but not set rx credits on the peripheral (using Telit 4.0 Bluetooth low, energy module) and am trying to get communication to work so don't think have to set Bluetooth permissions The problem I think is the pointer (Intpr) pointing to the wrong address as app crashes, when it deferences the data.
Thanks for the input though.
Regards nick

Welcome to SO ! You'd better update content all in question , then other people will know problem more clearly .
Although not knowing why NSData.FromBytes occurs error , however there is a workaround for you to check . Using NSData.FromArrayto transfer int to NSData .
int valueInt = 1234567890;
Byte[] byteData = new Byte[1];
byteData[0] = (Byte)((valueInt & 0xFF));
Console.WriteLine("-----NSData-------" + NSData.FromArray(byteData));
Then output is :
-----NSData-------{length = 1, bytes = 0xd2}
Therefore , shared code can be modified as follow :
...
Byte[] byteData = new Byte[1];
byteData[0] = (Byte)((this.PendingLocalUARTCreditsCount & 0xFF));
NSData valueData = NSData.FromArray(byteData);
...

Related

Samba(v 4.10.16) win10 can't open the files(like .xlsx .pptx) that has set extended attribute by setxattr() in centos7

Please forgive my broken English
I try to use setxattr() to sets the value of the extended attribute for some file, the code is like that:
int set_scl(string file_name, char scl)
{
char scl_data[16];
scl_data[0] = scl;
ssize_t size = 1;
size = setxattr(file_name.c_str(), "user.DosStream.easescl", scl_data, size, 0);
if (size == -1)
{
perror("set scl:");
return -1;
}
return 0;
}
But once I do this to a file (e.g 1234.xlsx) and then I can't open it however I can still see it. The Excel's error message is:
Can't find \\192.168.2.163\wy\1234.xlsx.
By the way in smb.cnf I have already set vfs objects = acl_xattr streams_xattr like https://www.samba.org/samba/docs/current/man-html/vfs_streams_xattr.8.html
When I use Process Monitor to trace it, I find one event's path is \\192.168.2.163\wy\1234.xlsx:easescl, the operation is 'CreateFile' and the result is 'NAME NOT FOUND'
What should I do to solve this?
I find two ways so far,
1)add "streams_xattr:store_stream_type = no" to smb.conf
2)add ":$DATA" to my code like that
size = setxattr(file_name.c_str(), "user.DosStream.easescl:$DATA", scl_data, size, 0);
Both of them are worked,and now i can open the file
However,the value about xattr i set before will be changed once i modify the file and save it, i can't find way to solve it .....

Hide DirectX9 game window on ShellExecute or CreateProcess

I have been trying both ShellExecute and CreateProcess to Launch a game - My goal is to hide the game window. The game is built using DirectX9. For some reason I am struggling on this issue. I am using the following codes independently but without success
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = app_exe; // Path to game
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
And with CreateProcess
ZeroMemory(&procInfo, sizeof(PROCESS_INFORMATION));
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
startupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
startupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
startupInfo.wShowWindow = SW_HIDE;
CreateProcess(app_exe, cmdline, NULL, NULL, FALSE,CREATE_NO_WINDOW , NULL, NULL,&startupInfo, &procInfo);
WaitForSingleObject(procInfo.hProcess, INFINITE);
In both cases the game is launched and I get a full-screen game.
Is there anything wrong that I am doing?
The STARTUPINFO.wShowWindow flag ends up in WinMain as the final parameter nCmdShow (https://msdn.microsoft.com/en-us/library/windows/desktop/ff381406(v=vs.85).aspx). There is no requirement that the created process adheres to this request. It is free to create as many visible windows as it likes. In fact, it's commonplace to completely ignore this flag. If you have the source code to the application being launched, and can recompile it, you could make it respect this request.
Also, I haven't tried it, but I would think that attempting to hide a DirectX fullscreen window will likely fail, and/or cause issues.

Can't set the value of textItem.contents

I am trying to write a script that will update the value of a text layer in Photoshop.
I have a layer stored in a variable myLayer which I log out so I know it is an ArtLayer with a type of LayerKind.TEXT and has a textItem object associated that has a string value in place. All as I would expect.
The documentation says that textItem.contents is read-write so I thought myLayer.textItem.contents = "Hello World" should update the value but when I try this I get General Photoshop Error occurred. This functionality might not be available in this version of Photoshop.
Can anyone advise on what I'm missing?
I am using Photoshop CC 2014 and the CC 2014 Javascript Reference
Thankyou in advance for you help :)
Its hard to see whats going wrong when there is no code example. This works for me.
Tested in PS CC 2014 Mac OSX
// needs a Photoshop document with only one textlayer
var d = app.activeDocument;
var l = d.artLayers[0];
if(l.hasOwnProperty ("textItem")){
$.writeln("yes");
l.textItem.contents = "Hello World";
}
This works in CS2: (Assuming the active layer (mylayer) is a text layer)
var srcDoc = app.activeDocument;
var myLayer= srcDoc.activeLayer;
var text = myLayer.textItem.contents;
myLayer.textItem.contents = "Hello World";

Convert CSV to Excel Windows Phone 8

with windows phone 8 I need to be able to open a CSV file in Excel using C#. Their is an app on the market now called Excel Extensions that converts the csv file locally.
I have tired converting the CSV file using open office XML but that didn't work. and I want to do it locally so no web services.
Anyone know how I can convert the CSV file to Excel on the Windows Phone 8 platform?
THEORY
You have a two distinct options: (1) doing most of the work on the WP8 client (2) or doing most of the work on a remote server.
For option #2 of using a remote server: Expose a WCF service that takes in the CSV file, parses the CSV to find its logical 2D table structure, use ClosedXML to save a new XLSX file and return that to the client. This option is the most straightforward but also requires network connectivity and a hosted server.
For option #1 of not using a remote server: read the CSV file, copy the CSV data into to an XLSX file, save the XLSX into IsoStore and launch excel with that file. I've written about this topic in the past # How can we create, write and read an excel file for Windows Phone 8
One thing you'll have to do quite a lot of work is writing a XLSX file in pure WP7 C#. You'll either have to convert 3rd party libraries that write XLSX to support WP7/WP8, or convert simple end-to-end C# code samples to WP7/WP8. Both aren't simple. Converting ClosedXML is possible but DocumentFormat.OpenXml's dependency on WPF's WindowsCore is a problem. Another option is to write your own OpenXML C# implementation like Chris Klug did here for Word OpenXML on Silverlight and was ported to WP7 later on. The key is using OpenXML specification for your advantage.
LIVE CODE SAMPLE
For example, looking at Chris Klug's Silverlight Excel OpenXML article it's possible to take his code for Ag.OpenXML and OpenXML.Silverlight.Spreadsheet port those to WP8 and then simply invoke them. I did just that. Here's how to get that experimental source code and get started:
1) Download and unzip # http://JustinAngel.net/Storage/OpenXML.Silverlight.Spreadsheet.WP8.zip
2) Add a reference to the csproj, or to the DLLs OpenXML.Silverlight.Spreadsheet.WP8.dll & SharpZipLib.dll from "OpenXML.Silverlight.Spreadsheet.WP8\Bin\Debug".
3) Add the following code snippet that saves a SpreedsheetDocument file into your app's WP8 IsoStore and then launches it in Word using WP8 app2app file associations.
private async void SaveXlsxToIsoStoreAndLaunchInExcel(SpreadsheetDocument doc)
{
using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isoStore.FileExists("myFile.xlsx"))
isoStore.DeleteFile("myFile.xlsx");
using (var s = isoStore.CreateFile("myFile.xlsx"))
using (IStreamProvider storage = new ZipStreamProvider(s))
{
doc.Save(storage);
}
Launcher.LaunchFileAsync(
await ApplicationData.Current.LocalFolder.GetFileAsync("myFile.xlsx"));
}
}
4) Invoke the above code snippet with Chris's sample document:
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
SpreadsheetDocument doc = new SpreadsheetDocument();
doc.ApplicationName = "SilverSpreadsheet";
doc.Creator = "Chris Klug";
doc.Company = "Intergen";
SharedStringDefinition str1 = doc.Workbook.SharedStrings.AddString("Column 1");
SharedStringDefinition str2 = doc.Workbook.SharedStrings.AddString("Column 2");
SharedStringDefinition str3 = doc.Workbook.SharedStrings.AddString("Column 3");
doc.Workbook.Sheets[0].Sheet.Rows[0].Cells[0].SetValue(str1);
doc.Workbook.Sheets[0].Sheet.Rows[0].Cells[1].SetValue(str2);
doc.Workbook.Sheets[0].Sheet.Rows[0].Cells[2].SetValue(str3);
doc.Workbook.Sheets[0].Sheet.Rows[1].Cells[0].SetValue("Value 1");
doc.Workbook.Sheets[0].Sheet.Rows[1].Cells[1].SetValue(1);
doc.Workbook.Sheets[0].Sheet.Rows[1].Cells[2].SetValue(1001);
doc.Workbook.Sheets[0].Sheet.Rows[2].Cells[0].SetValue("Value 2");
doc.Workbook.Sheets[0].Sheet.Rows[2].Cells[1].SetValue(2);
doc.Workbook.Sheets[0].Sheet.Rows[2].Cells[2].SetValue(1002);
doc.Workbook.Sheets[0].Sheet.Rows[3].Cells[0].SetValue("Value 3");
doc.Workbook.Sheets[0].Sheet.Rows[3].Cells[1].SetValue(3);
doc.Workbook.Sheets[0].Sheet.Rows[3].Cells[2].SetValue(1003);
doc.Workbook.Sheets[0].Sheet.Rows[4].Cells[0].SetValue("Value 4");
doc.Workbook.Sheets[0].Sheet.Rows[4].Cells[1].SetValue(4);
doc.Workbook.Sheets[0].Sheet.Rows[4].Cells[2].SetValue(1004);
TablePart table = doc.Workbook.Sheets[0].Sheet.AddTable("My Table", "My Table", doc.Workbook.Sheets[0].Sheet.Rows[0].Cells[0], doc.Workbook.Sheets[0].Sheet.Rows[4].Cells[2]);
table.TableColumns[0].Name = str1.String;
table.TableColumns[1].Name = str2.String;
table.TableColumns[2].Name = str3.String;
doc.Workbook.Sheets[0].Sheet.AddColumnSizeDefinition(0, 2, 20);
doc.Workbook.Sheets[0].Sheet.Rows[5].Cells[1].SetValue("Sum:");
doc.Workbook.Sheets[0].Sheet.Rows[5].Cells[2].Formula = "SUM(" + doc.Workbook.Sheets[0].Sheet.Rows[1].Cells[2].CellName + ":" + doc.Workbook.Sheets[0].Sheet.Rows[4].Cells[2].CellName + ")";
SaveXlsxToIsoStoreAndLaunchInExcel(doc);
}
5) When running this code snippet we can see the following warning popup and then the excel spreadsheet. Feel free to improve upon my hasty Silverlight-->WP8 port and remove that warning.

Setup Project Custom Action in C++ "[TARGETDIR]"

I am trying to copy file into the setup target directory.
I am using this:
TCHAR destPath[ MAX_PATH ] = &L"[TARGETDIR]";
wcscat_s(destPath, L"LiveFo#nextjmp.com\\Capture.png");
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", destPath, 0);
if I use this:
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", L"C:\\Program Files (x86)\\Microsoft\\Setup1\\LiveFo#nextjmp.com\\Capture.png", 0);
it works, which is basically what destPath should evaluate to, I can see that it evaluates when I use PMSIHANDLE, it alerts the correct path...
How do I force CopyFile to evalue "[TARGETDIR]";
WCHAR vbuff [MAX_PATH] = {0};
DWORD vlen = MAX_PATH;
UINT gp = MsiGetPropertyW(hInstall, L"CustomActionData", vbuff, &vlen);
in the Install Custom Action in property CustomactionData, I just put [TARGETDIR]
vbuff is the target directory
then of course the concatenation and the FileCopy executed as expected...
this worked for me... but I still would like to know why, it didn't in the original question I posted, the strangest thing was that the PMSIHANDLE wrote out the correct path, but I guess there "translation" step was missing in passing it in the FileCopy function...
I am sure I am missing some theory on this.
Assuming this is part of a custom action, you can use MsiFormatRecord. Error handling omitted, it would look something like this:
PMSIHANDLE hRec = MsiCreateRecord(1);
MsiRecordSetString(hRec, 0, _T("[TARGETDIR]LiveFo#nextjmp.com"));
TCHAR szPath[MAX_PATH] = {0};
DWORD cchPath = MAX_PATH;
MsiFormatRecord(hInstall, hRec, szPath, &cchPath);

Resources