I'm using SmartAssembly for both general code obfuscation as well as error reporting in an application.
If my application encounters an unhandled exception, I'd like the exception to be logged and then terminate the application without any user interaction. Is it possible to create a SmartAssembly project that allows this?
I've tried setting up the project in the SmartAssembly GUI, as well as on the command-line with no luck. Below is the command and arguments I've tried, but so far I can't determine how to get it to both terminate the app and log the error with no user input.
Create SA Project:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com"
/create shell.saproj input=C:\Repositories\MyApp\src\shell.exe
/output=shell.exe
/reportappname="MyTestApp"
/errorreportingtemplate=standard;continueonerror=false,email:"my#email.com"
/reportprojectname="Shell"
/reportcompanyname="My Company"
Build the project:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj
SmartAssembly includes a few examples of custom ErrorReportingTemplates,
located in Red Gate/SmartAssembly 6/SDK/Exception Reporting/
The examples are lumped into a few categories:
Without UI
Standard
Custom UI
Via Email
Secured Proxy
Silverlight
Silverlight Basic
In each of these folders, there is a .csproj file that one can extend to get their desired results.
Inside the Without UI folder is the project we're after, titled Sample 01 - Without User Interface.csproj
If you're just after a .dll to use and don't care about a re-usable solution, edit this file directly and use the resulting .dll file (the alternative being to create a new project, and pull in the reference to SmartAssembly.SmartExceptionsCore).
Edit the OnReportException function to look like the following:
protected override void OnReportException(ReportExceptionEventArgs e)
{
for (int i=0; i<3; i++)
{
if (e.SendReport()) break;
}
e.TryToContinue = false;
System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
proc.Kill();
}
Here's a Gist of the final result, if you're confused.
Create the project file with the GUI or via cmd:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com"
/create shell.saproj input=C:\Repositories\MyApp\src\shell.exe
/output=shell.exe
/reportappname="MyTestApp"
/errorreportingtemplate=MySmartAssemblyLogger.dll;continueonerror=false,email:"my#email.com"
/reportprojectname="Shell"
/reportcompanyname="My Company"
Build with the GUI or via cmd:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj
According to the example on the website http://www.red-gate.com/supportcenter/Content/SmartAssembly/help/6.7/SA_UsingTheCommandLine
You should replace "standard" with "auto" and that is supposed to send the error report without the user dialog appearing.
Related
After booting SWUpdate yocto-generated image for the first time, executing swupdate results in error message:
Error parsing configuration file: 'globals' section missing, exiting.
I tried to strictly follow SWUpdate's documentation, but it gets short when it comes to yocto integration. I'm using meta-swupdate, meta-swupdate-boards, and meta-openembedded layers together with poky example repository all at Kirkstone tag, building via bitbake update-image and having modyfied local.conf as:
MACHINE ??= "raspberrypi4-64"
ENABLE_UART = "1"
RPI_USE_U_BOOT = "1"
IMAGE_FSTYPES = "wic ext4.gz"
PREFERRED_PROVIDER_u-boot-fw-utils = "libubootenv"
IMAGE_INSTALL:append = " swupdate"
Is there anything else I need to modify to generate the configuration file and be able to run SWUpdate binary properly?
Side question: In the documentation, it's recommended to append swupdate-www to achieve a better web server. However, if I append it, there is no swupdate-www binary inside the `/usr/bin' directory.
As with other recipes folders the recipes-support/swupdate/swupdate/raspberrypi4-64 folder was missing inside the meta-swupdate-boards layer. Therefore, an empty config file was always generated. After adding this folder and all related files, strongly inspired by raspberrypi3 folder, the error was gone and swupdate -h provided the expected output.
There was also one new error during build process thrown by yocto. It was related to missing systemd requirement and was solved by adding:
DISTRO_FEATURES_append = " systemd"
to local.conf
Goodday guys,
I am trying to build and run program in linux (raspberry) as a service.
It is a sample application that uses the Cerence SDK C API that implements a wake-up-word (WUW) plus command utterance recognition.
I can execute it by ./name.exe or using the Makefile commands.
The problem is that when I execute the program by console it works fine, without any problem.
When I try to execute it as a service (using both systemd or crontab and also rc.local), an error occours.
This is the function that gives me error:
printf("Selecting audio configuration %s\n", audioScenarioName);
rc = nuance_audio_IAudioManager_activateScenario(audioMgr, audioScenarioName);
if (NUANCE_COMMON_OK != rc) {
printf("Audio scenario activation failed: %d\n", rc); <-- returns 1 (error, impossible to activate scenario)
return rc;
}
ActivateScenario it's a function that simply selects the correct mic (audioScenarioName) following a JSON file and the audio manager (audioMgr).
Unfortunately this function returns 1 if something goes wrong, closes the program and nothing else.
This is the JSON:
"type": "AudioInput",
"name": "mic_input",
"adapter_type": "CUSTOM_AUDIO",
"adapter_params": {
"device_name": "default"
},
"audio_format": { "uses": "16khz_1ch" }
The service should be running as root permissions (default).
I also tried by setting the whole folder as chmod -R 777 as a test, but same problem.
This is my service:
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=+/home/pi/.../nameexec
Restart=on-failure
RestartSec=5
KillMode=process
[Install]
WantedBy=multi-user.target
I've also set the absolute path of its lib directory that it needs into the ld.so.conf file.
The only libraries I put in it are the .so ones, but not .h.
I am now trying to understand what might be different about starting the same executable but in different ways.
Could it be a permissions issue? Or is it not detecting the microphone? Any library out of place?
I really don't know why it works with the classic command and not as a service.
Can someone please help me with this?
Thank you in advance!
I succeeded!
The problem was the microphone being used.
Using Raspbian ver. Desktop, I set the mic from the bottom right part of the taskbar and changed the defaults in/out.
But these settings seem to be not system-wide and not used by the services in background (even though the "User=" is set to "pi").
So I had to change alsa.conf file:
sudo nano /usr/share/alsa/alsa.conf
Then find and edit these lines:
defaults.ctl.card cardnumber
defaults.pcm.card cardnumber
You can find the card number by running arecord -l.
I created a tiny OS for my controller with Linux kernel 2.6.37.6 with the help of BusyBox and tool chain. I am writing a logging module(C program) in it and i want customized logs(customized path for different logs) like in /log/.
I have syslogd in my machine and /etc/syslog.conf supposed to present in my machine but it's not it the place. I created new syslog.conf under /etc but still i can't find my logs in desired place.
But if i run command syslogd -O /log/Controller.log all logs started to redirect to this (specified file). So i want to know where is the configuration file for this syslogd i can't find the configuration file for it.
Is there any way that i can write a module(program) for LOGS without requiring syslog.conf and yes of course traditional printf way. Problem is that for customized paths for log we need to give keyname LOG_LOCAL1 in openlog() as a argument but it's not working
I followed procedure from this examples http://www.codealias.info/technotes/syslog_simple_example
If you are using Busybox's syslogd then there is no support of syslog.conf,all logs are written to /var/log/messages by default.
You can modify code of syslogd in busybox which is located in busybox/sysklogd/syslogd.c for your desire behaviour
You can change code of syslogd like this
static const struct init_globals init_data = {
.logFile = {
.path = "your desire path",
.fd = -1,
},
I am AI student and we work with JavaCC.
I am new with it. I was trying simple example and I had some errors.
1) I downloaded JavaCC 0.6 from it's website
2) I extracted it in disc C
3) I wrote this code in a file with extension ".jj"
PARSE_BEGIN(Test)
import java.io.*;
class Test
{
public static void main(string [] args)
{
new Test(new InputStreamReader(System.in));
start();
}
}
PARSE_END(Test);
Token:
{
<number: (["0"-"9"])+("." (["0"-"9"])+)?(("e"|"E")(["0"-"9"])+)?>|
<plus: "+">
}
void start():
{ }
{
<number>(<plus><number>)*
}
4) I saved it and put it in javacc/bin folder
5) I wrote this line in command
..."my Path"..javacc Test.jj
6) I had this error
Could not find or load main class javacc
Is there something I have to install before these steps?
thx in advance
Use version 5 at https://java.net/projects/javacc/downloads . Version 6.0 is missing the scripts to run JavaCC. If you really want to use version 6.0 you can find the appropriate scripts in version 5, just copy them to version 6's bin directory and away you go.
Update (2020): Since version 6 is now harder to find, I have put a copy at www.engr.mun.ca/~theo/JavaCC/javacc-6.1.0.zip
I selected the step you missed in bold below.
The download should have placed into your file system either a ZIP or
GZIP file containing the JavaCC software. You should go to the directory
where the archive was installed and unzip it's contents. That
completes your installation.
Once you have completed installation, add the bin directory within
the JavaCC installation to your path. The javacc, jjtree, and jjdoc
invocation scripts/executables reside in this directory.
You need to modify PATH system variable in windows (wild guess on used OS).
For example as described in
http://www.computerhope.com/issues/ch000549.htm
http://www.java.com/en/download/help/path.xml
...
I've uploaded my app to google. It has been published. My main exp file was uploaded with app version code 2 and it still bears the same name. My main app is right now at version code 4 and is still using the main.2 exp file.
I've already tested the file with my app through debug.
I've created a test account and i'm signed in on the device with that account and tried downloading 20 minutes after creating that test account.
I believe my file size is correct too. I'm using the the size from the properties 155,630,535 bytes and set it to 155630535L. There is another one called as size on disk which I'm not using.
I've uploaded my apk over 12 hours ago.
Really don't know where I'm going wrong. The only thing I wonder about is my version name which is 1.13. Do I need to use this anywhere?
I'm having problems downloading my expansion files. Initially I was getting 'download failed because you may not have purchased this app'. Now after recompiling (export file) the apk file and uninstalling it and reinstalling it to my device, I've uploaded it to my publish account and now I get 'resources could not be found'. Please help...
ok. I've resolved my issues after a lot of struggling by myself.
First, it's the size of the file in bytes only and not the size of the file in bytes on the disk.
Secondly, they have moved the test account into settings. You need to create a test account.
Thirdly, the app needs to be saved in draft mode. The expansion files will not download while testing using the test account, if the app has been published.
I hope this will help someone.
Some helfull information for people that end up here in this post since there are some things that changed in the way apk expansions work and also if you are using Android Studio to make the libraries work.
NOTE 1
You can't use draft anymore as the link to get the expansion file won't be active yet. You have to upload a version to Alpha or Beta first with expansion file. (adding an expansion file is only possible from the second apk you upload and up) So make sure you see the apk expansion file listed when you click the details in the developer publish section under APK.
NOTE 2
If you are using android studio and want to make use of the downloader library don't just copy the package name and java files into your own app src directory. Import the downloader library in eclipse and choose export => gradle build files. Afterwards you can import the library as a module in android studio.
NOTE 3
Not sure of this but I also think it's neccesary to download the app atleast once through the play store and have access to it with the account on your test device. So if you are working with alpha create a google+ test group and add yourself or other test devices to it.
BTW
With these libraries it's pretty easy to implement the apk expansion download just make sure:
your activity (the one where you want to implement the downloading
of the expansion pack when the downloading has not been done
automatically) implements IDownloaderClient.
you set up the service & receiver and set them up in your manifest.
The BASE64_PUBLIC_KEY in the service class is correct. Upload the
first apk => look in Services and API's in the developer console
under your app => License code for this app.
This code is used to see if the expansion file can be found on the device:
boolean expansionFilesDelivered() {
for (XAPKFile xf : xAPKS) {
String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
Log.i(TAG, "Expansion filename " +fileName);
if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false))
return false;
}
return true;
}
It uses the class XAPKS wich represents an expansion file, be it either a main or patch file, having a certain filesize(bytes) and associated with a apk version (the one it was first added in).
private static class XAPKFile {
public final boolean mIsMain; // true
public final int mFileVersion; //example 4
public final long mFileSize; //example 126515695L
// example => main expansion that was first introduced in apk version 4 and is 126515695 bytes in size
XAPKFile(boolean isMain, int fileVersion, long fileSize) {
mIsMain = isMain;
mFileVersion = fileVersion;
mFileSize = fileSize;
}
}
Its also quite easy to read movie files and other stuff directly from the expansion file using the zip tools that google has provided (com.android.vending.zipfile).
First get the expansionfile using the methods provided in the library, the paremeters are integers that represent your main expansion apk version (the apk version where the expansion pack you need was first added) and the patch apk version.
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(context, APKX_MAIN_APK, APKX_PATCH_APK);
Video
For playing video directly from this zipresourcefile:
AssetFileDescriptor a = expansionFile.getAssetFileDescriptor(pathToFileInsideZip);
Now from this assetFileDescriptor you can get a FileDescriptor and use this in your mediaplayer, the correct syntax to get your mediaplayer to play the video also needs the second and third parameter.. Be it the startoffset and length you can get from the AssetFileDescriptor.
player.setDataSource(a.getFileDescriptor(), a.getStartOffset(), a.getLength());
Other
For all the other stuff (like images) you can just get an inputstream of the zipresourcefile:
expansionFile.getInputStream(pathToFileInsideZip);`
ALSO make sure you don't compress the videos in the zip for this to work!
for example not to compress .mp4 files:
zip -n .mp4 -r zipfile.zip . -x ".*" -x "*/.*"