Browse Category

Informatica

Call WCF Web Service from Rasberry PI (Raspbian)

Install Gsoap on Rasberry PI running Raspbian

sudo apt-get install gSoap

Check installed gSoap version (May 1,2014 version is 2.8.7)

Download the correspondent toolchain (class generator) from sourgeforce (Installed library and toolchain must have SAME VERSION!)

Open console as Administrator and go to the tools folder. For Example:

cd C:\gsoap\gsoap-2.8.7\gsoap\bin\win32

Then use toolchain to build file as follow for c++:

wsdl2h -o test.h http://yourws.net/yourWCF/Service1.svc?wsdl
soapcpp2 -I"C:\gsoap\gsoap-2.8.7\gsoap\import" test.h

Import all generated files in your project (Exclude test.h , soapClientLib.cpp and soapServerLib.cpp)

Add stdsoap2.cpp and stdsoap2.h from toolchain directory.

Include *.nsmap and *Proxy.h in header.

Code Example

#include "Soap/BasicHttpBinding_USCOREIService1.nsmap"
#include "Soap/soapBasicHttpBinding_USCOREIService1Proxy.h"

int main(int argc, char *argv[])
{

BasicHttpBinding_USCOREIService1 s;
_ns1__GetData req;
_ns1__GetDataResponse resp;

int i = 29;
req.value = &i;

int err = s.__ns1__GetData(&req,&resp);

if (SOAP_OK == err)
cout << "WCF Response: " << *resp.GetDataResult << endl;
else
cout << "Error: " << err << endl;

}

Now you can see result in your console:

WCF Response: You entered: 29

If you receive Error 415 (Bad request) you have to change SOAP operation mode (WCF use an unusual charset for SOAP 1.1).

For removing soap 1.2 namespace from the your web-service client project you should to change strings

{"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://www.w3.org/2003/05/soap-envelope", NULL},
 {"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://www.w3.org/2003/05/soap-encoding", NULL},
 {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
 {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},

to

{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", NULL, NULL},
 {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", NULL, NULL},
 {"xsi", "http://www.w3.org/2001/XMLSchema-instance", NULL, NULL},
 {"xsd", "http://www.w3.org/2001/XMLSchema", NULL, NULL},

in all your .nsmap file and *Proxy.cpp file.

Far lampeggiare un led con Rasberry PI

Il modo più rapido per far lampeggiare un led tramite Raspberry Pi è utilizzando il connettore e l’interfaccia GPIO.

Collegare il led (dopo averlo protetto con una deguata resistenza) al connettore (In questo esempio utilizziamo le porte 13 e 14)

Importare la libreria WiringPI (la più completa per la gestione dell’interfaccia GPIO del Raspberry PI. Leggi come importarla).

Il codice

#include <wiringPi.h>
#include "stdio.h"

int main(int argc, char *argv[])
{
    wiringPiSetup();
    const int pinNumber = 2;

    pinMode(pinNumber, OUTPUT);

    for (int i=1; i<=1000;i++)
    {
        digitalWrite(pinNumber, HIGH);
        delay(100);
        digitalWrite(pinNumber, LOW);
        delay(100);
    }
    return 0;
}

Installare WiringPI su Rasberry PI (Raspbian)

WiringPI è la libreria più completa per la gestione dell’interfaccia GPIO del Raspberry PI.
E’ distribuita tramite GIT e la via più facile per scaricare ed installare la libreria è quindi tramite git-core.

Per installare GIT accedere alla console e dare il comando:

sudo apt-get install git-core

Se si verificano degli errori verificare di avere Raspbian aggiornato. E’ possibile aggiornare il sistema operativo tramite i comandi:

sudo apt-get update
sudo apt-get upgrade

Per ottenere WiringPI tramite GIT:

git clone git://git.drogon.net/wiringPi
cd wiringPi
git pull origin

Per compilare ed installare la libreria non rimane altro che fare il build:

cd wiringPi
./build

Ora potete usare la libreria per comandare le porte del rasberry PI (Esempi di utilizzo)

Per testare la corretta installazione e vedere lo stato della GPIO

gpio -v
gpio readall

BizSpark: una grande opportunità per noi!

Da oggi ikrotec è nella galassia Microsoft BizSpark.

 

 

BizSpark è un programma globale pensato da per accelerare il successo delle startup selezionate.  Microsoft fornirà gratuitamente ai partner: software, supporto, consulenza tecnica/business e visibilità marketing nazionale ed internazionale. Inoltre è garantito un accesso privilegiato alla piattaforma Windows Azure  e all’assistenza focalizzata sul tema del Cloud e dei device, Windows Phone 7.5 e Windows 8..

 

AutocompleteTextView: esempio semplice utilizzo – Android

Questo esempio mostra come utilizzare l’AutocompleteTextView utile per facilitare l’immissione di un testo predefinito nella TextView

import java.util.Vector;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class Prova extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    	Vector name=new Vector();
    	name.add("Mario Rossi");
    	name.add("Francesco Verdi");
    	name.add("Pino Giallo");
    	name.add("Giulia Blu");

        ArrayAdapter adapter = new ArrayAdapter(this,
                android.R.layout.simple_dropdown_item_1line, name);
        AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.AutoCompleteTextView01);
        textView.setAdapter(adapter);
    }
}

Scarica l’esempio:[download id=”2″]

Registrare/Deregistrare una DLL o un OCX in Windows

Per registrare una DLL o un file OCX si utilizza il comando regsvr32 specificando il percorso del file. La deregistrazione/rimozione/unregsvr32 si ottiene semplicemente aggiungendo il parametro -u .

Esempio di registrazione:

regsvr32 C:\WINDOWS\system32\Nicola.ocx

Esempio di rimozione:

regsvr32 -u C:\WINDOWS\system32\Nicola.ocx

Gestione processi in Visual Basic

Esempio di ciclo per verificare l’esistenza di un processo e killarlo:

    Dim cnt As Integer 'tentativi.
    cnt = 10
    Do While IsProcessRunning("nomeprocesso.exe") = True
        
        If cnt = 0 Then
             Exit Do
        End If
        
        KillProcess ("nomeprocesso.exe")
        cnt = cnt - 1
        Sleep (2000)
    Loop

Verificare l’esistenza di un processo:

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long

Private Declare Function EnumProcesses Lib "PSAPI.DLL" ( _
lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long

Private Declare Function EnumProcessModules Lib "PSAPI.DLL" ( _
ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long

Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias "GetModuleBaseNameA" ( _
ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long

Private Const PROCESS_VM_READ = &H10

Private Const PROCESS_QUERY_INFORMATION = &H400


Public Function IsProcessRunning(ByVal sProcess As String) As Boolean
    Const MAX_PATH As Long = 260
    Dim lProcesses() As Long, lModules() As Long, N As Long, lRet As Long, hProcess As Long
    Dim sName As String
    sProcess = UCase$(sProcess)
    ReDim lProcesses(1023) As Long
    If EnumProcesses(lProcesses(0), 1024 * 4, lRet) Then
        For N = 0 To (lRet \ 4) - 1
            hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, lProcesses(N))
            If hProcess Then
                ReDim lModules(1023)
                If EnumProcessModules(hProcess, lModules(0), 1024 * 4, lRet) Then
                    sName = String$(MAX_PATH, vbNullChar)
                    GetModuleBaseName hProcess, lModules(0), sName, MAX_PATH
                    sName = Left$(sName, InStr(sName, vbNullChar) - 1)
                    If Len(sName) = Len(sProcess) Then
                        If sProcess = UCase$(sName) Then IsProcessRunning = True: Exit Function
                    End If
                End If
            End If
            CloseHandle hProcess
        Next N
    End If
End Function

Killare un processo:

Public Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szexeFile As String * 260
End Type

Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, _
ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long

Declare Function ProcessFirst Lib "kernel32.dll" Alias "Process32First" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long

Declare Function ProcessNext Lib "kernel32.dll" Alias "Process32Next" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long

Declare Function CreateToolhelpSnapshot Lib "kernel32.dll" Alias "CreateToolhelp32Snapshot" ( _
ByVal lFlags As Long, lProcessID As Long) As Long

Declare Function TerminateProcess Lib "kernel32.dll" (ByVal ApphProcess As Long, _
ByVal uExitCode As Long) As Long

Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long

Public Sub KillProcess(NameProcess As String)
    Const PROCESS_ALL_ACCESS = &H1F0FFF
    Const TH32CS_SNAPPROCESS As Long = 2&
    Dim uProcess  As PROCESSENTRY32
    Dim RProcessFound As Long
    Dim hSnapshot As Long
    Dim SzExename As String
    Dim ExitCode As Long
    Dim MyProcess As Long
    Dim AppKill As Boolean
    Dim AppCount As Integer
    Dim i As Integer
    Dim WinDirEnv As String

       If NameProcess <> "" Then
          AppCount = 0

          uProcess.dwSize = Len(uProcess)
          hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
          RProcessFound = ProcessFirst(hSnapshot, uProcess)

          Do
            i = InStr(1, uProcess.szexeFile, Chr(0))
            SzExename = LCase$(Left$(uProcess.szexeFile, i - 1))
            WinDirEnv = Environ("Windir") + "\"
            WinDirEnv = LCase$(WinDirEnv)

            If Right$(SzExename, Len(NameProcess)) = LCase$(NameProcess) Then
               AppCount = AppCount + 1
               MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
               AppKill = TerminateProcess(MyProcess, ExitCode)
               Call CloseHandle(MyProcess)
            End If
            RProcessFound = ProcessNext(hSnapshot, uProcess)
          Loop While RProcessFound
          Call CloseHandle(hSnapshot)
       End If

End Sub

Esportare dati in formato ODS (Foglio di Calcolo OpenDocument)

public static void ExportToOds(DataSet source, string fileName)
{
   System.IO.StreamWriter excelDoc;
   excelDoc = new System.IO.StreamWriter(fileName);
   excelDoc.Write("<table>");
   excelDoc.Write("<tr>");

   for (int x = 0; x < source.Tables[0].Columns.Count; x++)
   {
      excelDoc.Write("<td align=\"left\" valign=\"middle\" width=\"100%\"><strong>");
      excelDoc.Write(source.Tables[0].Columns[x].ColumnName);
      excelDoc.Write("</strong></td>");
   }

   excelDoc.Write("</tr>");

   foreach (DataRow x in source.Tables[0].Rows)
   {
      excelDoc.Write("<tr>");

      for (int y = 0; y < source.Tables[0].Columns.Count; y++)
      {
          excelDoc.Write("<td align=\"left\" valign=\"middle\">");
          excelDoc.Write(string.Format("{0}", x[y]));
          excelDoc.Write("</td>");
      }

      excelDoc.Write("</tr>");
   }

   excelDoc.Write("</table>");
   excelDoc.Close();
}

ICell – iPhoneTracker for Windows

ICell resume all your IPhone position history.

Version 0.2 – DOWNLOAD HERE >>>>>> [download id=”16″]<<<<<<<<<<

(Compiled Version, check if Framework 2.0 is present [download id=”14″] )

Changelog:

– Add Direct Map Viewer

– Add esport in light KML

– Add list mode viewer

——————————————————————————————————

Version 0.1 – DOWNLOAD HERE >>>>>> [download id=”12″]<<<<<<<<<<

How to use:

– Backup your IPhone by ITunes

– Download and run ICell

– Select your backup

– Save your file or Right Button and view in Google Maps


This application use Framework 2: Download here.

Based on http://petewarden.github.com/iPhoneTracker/

  • 1
  • 2