android串口读取ic卡

Former-commit-id: 56dda1534cf4e293aaf775afa2a411bba9224f0f
TangShanKaiPing
wanggang 6 years ago
parent 32d648bb58
commit e9ebcba47a

@ -20,8 +20,8 @@
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<AndroidKeyStore>false</AndroidKeyStore>
<AndroidSigningKeyStore>..\keystore\demo.keystore</AndroidSigningKeyStore>
<AndroidKeyStore>true</AndroidKeyStore>
<AndroidSigningKeyStore>C:\Users\WG\AppData\Local\Xamarin\Mono for Android\Keystore\demo\demo.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>123456</AndroidSigningStorePass>
<AndroidSigningKeyAlias>demo</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>123456</AndroidSigningKeyPass>
@ -34,11 +34,15 @@
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<AotAssemblies>false</AotAssemblies>
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
<AndroidEnableMultiDex>false</AndroidEnableMultiDex>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidSupportedAbis>
</AndroidSupportedAbis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -54,6 +58,9 @@
<BundleAssemblies>false</BundleAssemblies>
<MandroidI18n />
<EnableProguard>false</EnableProguard>
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
@ -66,7 +73,10 @@
<PackageReference Include="VideoLAN.LibVLC.Android">
<Version>3.1.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" />
<PackageReference Include="Xamarin.Android.SerialPort">
<Version>1.0.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.482894" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1" />

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.0-beta.108" package="com.nbaxp.Demo" android:installLocation="auto">
<uses-sdk android:minSdkVersion="22" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0.0-beta.108" package="com.nbaxp.Demo" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="22" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:label="Demo.Android" android:icon="@drawable/splash"></application>
</manifest>

@ -27,6 +27,8 @@ namespace Demo.Droid
public static void UpdateIdValues()
{
global::Plugin.LocalNotifications.Resource.Drawable.plugin_lc_smallicon = global::Demo.Droid.Resource.Drawable.plugin_lc_smallicon;
global::SerialPort.Resource.String.app_name = global::Demo.Droid.Resource.String.app_name;
global::SerialPort.Resource.String.hello = global::Demo.Droid.Resource.String.hello;
global::Xamarin.Forms.Platform.Android.Resource.Animation.abc_fade_in = global::Demo.Droid.Resource.Animation.abc_fade_in;
global::Xamarin.Forms.Platform.Android.Resource.Animation.abc_fade_out = global::Demo.Droid.Resource.Animation.abc_fade_out;
global::Xamarin.Forms.Platform.Android.Resource.Animation.abc_grow_fade_in_from_bottom = global::Demo.Droid.Resource.Animation.abc_grow_fade_in_from_bottom;
@ -7613,8 +7615,8 @@ namespace Demo.Droid
// aapt resource value: 0x7f080033
public const int abc_toolbar_collapse_description = 2131230771;
// aapt resource value: 0x7f08004f
public const int app_name = 2131230799;
// aapt resource value: 0x7f080050
public const int app_name = 2131230800;
// aapt resource value: 0x7f080041
public const int appbar_scrolling_view_behavior = 2131230785;
@ -7634,6 +7636,9 @@ namespace Demo.Droid
// aapt resource value: 0x7f080046
public const int fab_transformation_sheet_behavior = 2131230790;
// aapt resource value: 0x7f08004f
public const int hello = 2131230799;
// aapt resource value: 0x7f080047
public const int hide_bottom_view_on_scroll_behavior = 2131230791;

@ -43,11 +43,11 @@
<Reference Include="Geckofx-Winforms, Version=60.0.26.0, Culture=neutral, PublicKeyToken=3209ac31600d1857, processorArchitecture=x86">
<HintPath>..\packages\Geckofx60.32.60.0.26\lib\net45\Geckofx-Winforms.dll</HintPath>
</Reference>
<Reference Include="LibVLCSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LibVLCSharp.0.8.1\lib\net471\LibVLCSharp.dll</HintPath>
<Reference Include="LibVLCSharp, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LibVLCSharp.3.0.1\lib\net471\LibVLCSharp.dll</HintPath>
</Reference>
<Reference Include="LibVLCSharp.WinForms, Version=0.8.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LibVLCSharp.WinForms.0.8.1\lib\net40\LibVLCSharp.WinForms.dll</HintPath>
<Reference Include="LibVLCSharp.WinForms, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LibVLCSharp.WinForms.3.0.1\lib\net40\LibVLCSharp.WinForms.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -56,11 +56,11 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Unosquare.Labs.EmbedIO, Version=2.7.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EmbedIO.2.7.2\lib\net462\Unosquare.Labs.EmbedIO.dll</HintPath>
<Reference Include="Unosquare.Labs.EmbedIO, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EmbedIO.2.9.0\lib\netstandard2.0\Unosquare.Labs.EmbedIO.dll</HintPath>
</Reference>
<Reference Include="Unosquare.Swan.Lite, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Unosquare.Swan.Lite.1.1.2\lib\net461\Unosquare.Swan.Lite.dll</HintPath>
<Reference Include="Unosquare.Swan.Lite, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Unosquare.Swan.Lite.1.3.0\lib\net461\Unosquare.Swan.Lite.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@ -103,5 +103,10 @@
<Project>{a5c37aa5-4090-4000-9e1d-779593547c8a}</Project>
<Name>IoT.Resources.Standard</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /><Import Project="..\packages\Geckofx60.32.60.0.26\build\Geckofx60.32.targets" Condition="Exists('..\packages\Geckofx60.32.60.0.26\build\Geckofx60.32.targets')" /><Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"><PropertyGroup><ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText></PropertyGroup><Error Condition="!Exists('..\packages\Geckofx60.32.60.0.26\build\Geckofx60.32.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Geckofx60.32.60.0.26\build\Geckofx60.32.targets'))" /></Target></Project>

@ -28,10 +28,17 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.SuspendLayout();
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "MainForm";
this.Name = "MainForm";
this.Text = " ";
this.ResumeLayout(false);
}
#endregion

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -1,5 +1,4 @@
using Demo.Resources;
using System;
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unosquare.Labs.EmbedIO;
@ -21,7 +20,7 @@ namespace Demo.WinForms
{
using (var server = new WebServer("http://*:5000"))
{
server.RegisterModule(new ResourceFilesModule(Resource.Assembly, Resource.WebFolder));
server.RegisterModule(new ResourceFilesModule(IoT.Resources.Resource.Assembly, IoT.Resources.Resource.WebFolder));
await server.RunAsync();
}
});

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EmbedIO" version="2.7.2" targetFramework="net472" />
<package id="EmbedIO" version="2.9.0" targetFramework="net472" />
<package id="Geckofx60.32" version="60.0.26" targetFramework="net472" />
<package id="LibVLCSharp" version="0.8.1" targetFramework="net472" />
<package id="LibVLCSharp.WinForms" version="0.8.1" targetFramework="net472" />
<package id="Unosquare.Swan.Lite" version="1.1.2" targetFramework="net472" />
<package id="LibVLCSharp" version="3.0.1" targetFramework="net472" />
<package id="LibVLCSharp.WinForms" version="3.0.1" targetFramework="net472" />
<package id="Unosquare.Swan.Lite" version="1.3.0" targetFramework="net472" />
</packages>

@ -166,9 +166,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="VideoLAN.LibVLC.iOS">
<Version>3.1.5-alpha</Version>
<Version>3.1.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" />
<PackageReference Include="Xamarin.Forms" Version="4.0.0.482894" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>

@ -31,17 +31,5 @@ namespace Demo
});
MainPage = new NavigationPage(new MainPage());
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
}
protected override void OnResume()
{
}
}
}

@ -10,11 +10,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EmbedIO" Version="2.7.2" />
<PackageReference Include="EmbedIO" Version="2.9.0" />
<PackageReference Include="Flurl" Version="2.8.2" />
<PackageReference Include="LibVLCSharp.Forms" Version="0.8.1" />
<PackageReference Include="LibVLCSharp.Forms" Version="3.0.1" />
<PackageReference Include="NetCoreSerial" Version="1.3.1" />
<PackageReference Include="Xam.Plugins.Notifier" Version="3.0.1" />
<PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" />
<PackageReference Include="Xamarin.Forms" Version="4.0.0.482894" />
<PackageReference Include="ZXing.Net.Mobile" Version="2.4.1" />
<PackageReference Include="ZXing.Net.Mobile.Forms" Version="2.4.1" />
</ItemGroup>

@ -2,7 +2,7 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Demo.MainPage">
<StackLayout Orientation="Vertical" BackgroundColor="Green">
<WebView x:Name="webView" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Blue" />
<StackLayout Orientation="Vertical">
<WebView x:Name="webView" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
</StackLayout>
</ContentPage>

@ -1,5 +1,6 @@
using Plugin.LocalNotifications;
using System;
using System.IO.Ports;
using Xamarin.Forms;
using ZXing.Net.Mobile.Forms;
@ -7,6 +8,8 @@ namespace Demo
{
public partial class MainPage : ContentPage
{
private SerialDevice _sp;
public MainPage()
{
InitializeComponent();
@ -16,6 +19,67 @@ namespace Demo
this.webView.Source = "http://localhost:5000/index.html";
}
protected override void OnAppearing()
{
base.OnAppearing();
this.OpenSerialPort();
}
protected override void OnDisappearing()
{
base.OnDisappearing();
this.CloseSerialPort();
}
private void OpenSerialPort()
{
if (Device.RuntimePlatform == Device.Android)
{
try
{
this._sp = new SerialDevice("/dev/ttyS4", BaudRate.B9600, Parity.None, 8, StopBits.One, Handshake.None);
this._sp.DataReceived += (s, e) =>
{
try
{
if (e.Length > 0)
{
var message = BitConverter.ToString(e);
this.Alert(BitConverter.ToString(e));
}
}
catch (Exception ex)
{
this.Alert(ex.Message);
}
};
this._sp.Open();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
private void CloseSerialPort()
{
if (Device.RuntimePlatform == Device.Android)
{
try
{
if (this._sp != null)
{
this._sp.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
private void WebView_Navigating(object sender, WebNavigatingEventArgs e)
{
Console.WriteLine(e.Url);
@ -58,5 +122,13 @@ namespace Demo
};
this.Navigation.PushAsync(scanPage);
}
public void Alert(object message, string title = "Ìáʾ", string button = "È·¶¨")
{
Device.BeginInvokeOnMainThread(() =>
{
this.DisplayAlert(title, message.ToString(), button);
});
}
}
}

@ -54,8 +54,10 @@ namespace Demo
//media.AddOption(":clock-jitter=0");
//media.AddOption(":clock-synchro=0");
}
var player = new MediaPlayer(_libvlc);
player.Volume = 0;
var player = new MediaPlayer(_libvlc)
{
Volume = 0
};
videoView.MediaPlayer = player;
player.Play(media);
}
@ -127,7 +129,6 @@ namespace Demo
var url = videoUrl.QueryParams["host"].ToString() + "/App/Exec/";
url = url.SetQueryParam("node", videoUrl.QueryParams["node"]);
url = url.SetQueryParam("id", videoUrl.QueryParams["id"]);
var btn = sender as ImageButton;
url = url.SetQueryParam("cmd", "23stop");
Console.WriteLine(url);
var client = new HttpClient();

Loading…
Cancel
Save