- Open Setting, go to About Device
- Tap the Build Number 7 times
- Developer Options menu will appear
Monday, March 10, 2014
NO USB Debugging Mode in Android 4.2
Thursday, March 8, 2012
Pelco P and D protocol implementation in C#
PTZ camera have many type of protocol such as Samsumg-T, Pelco-P, Pelco-D, Bosch, Honeywell, Vicon, Ad, Samsung-E, Panasonic to supports commands. This is a full C# classes to control a PTZ cameras via RS422/485 Pelco 'P' and 'D' protocol.
Pelco-P
/*-------------------------------------------------------------------------------
* Author: Tamir Khason, 2004
* Email: tamir@khason.biz
* Web: http://www.dotnet.us/
*
* Freeware: Please do not remove this header
*
* File: P.cs
*
* Description: PELCO P Protocol Implementation dot.NET Way
* This is GPL software. Do with it as you want, but feed us back any improvements.
*
* This is a simple class to control a PELCO PTZ camera via RS422/485
* 'P' protocol. It supports all of the commands including UP, DOWN, IN, OUT, LEFT,
* RIGHT, NEAR, FAR, as well as all other extended commands.
*
* To use this, you need to put a RS232->RS422 adapter on the output
* of your desired serial port.
*
* The Pelco doesn't return ANY usefull info back, so you only really need 2-wire support
* (one way) communications out.
*
*
* Version: 1.4
* ------------------------------------------------------------------------------*/
using System;
using System.Collections;
//namespace Pelco
//{
///
/// dot.NET Implementation of Pelco P Protocol
///
public class P //: Pelco
{
private const byte STX = 0xA0;
private const byte ETX = 0xAF;
#region Pan and Tilt Commands
#region Data1
private const byte FocusFar = 0x01;
private const byte FocusNear = 0x02;
private const byte IrisOpen = 0x04;
private const byte IrisClose = 0x08;
private const byte CameraOnOff = 0x10;
private const byte AutoscanOn = 0x20;
private const byte CameraOn = 0x40;
#endregion
#region Data2
private const byte PanRight = 0x02;
private const byte PanLeft = 0x04;
private const byte TiltUp = 0x08;
private const byte TiltDown = 0x10;
private const byte ZoomTele = 0x20;
private const byte ZoomWide = 0x40;
#endregion
#region Data3
private const byte PanSpeedMin = 0x00;
private const byte PanSpeedMax = 0x40;
#endregion
#region Data4
private const byte TiltSpeedMin = 0x00;
private const byte TiltSpeedMax = 0x3F;
#endregion
#endregion
#region Enums
public enum PresetAction {Set,Clear,Goto}
public enum PatternAction {Start,Stop,Run}
public enum Action {Start,Stop}
public enum LensSpeed {Low=0x00,Medium=0x01,High=0x02,Turbo=0x03}
public enum Pan {Left = PanLeft,Right = PanRight}
public enum Tilt {Up = TiltUp,Down = TiltDown}
public enum Iris {Open = IrisOpen,Close = IrisClose}
public enum Zoom {Wide = ZoomWide,Tele = ZoomTele}
public enum Switch {On,Off}
public enum Focus {Near = FocusNear,Far = FocusFar}
#endregion
#region Extended Command Set
public byte[] Preset(uint deviceAddress, byte preset, PresetAction action)
{
byte m_action;
switch (action)
{
case PresetAction.Set:
m_action = 0x03;
break;
case PresetAction.Clear:
m_action = 0x05;
break;
case PresetAction.Goto:
m_action = 0x07;
break;
default:
m_action = 0x03;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,preset);
}
public byte[] Flip(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x21);
}
public byte[] ZeroPanPosition(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x22);
}
public byte[] AutoScan(uint deviceAddress, Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x09;
else
m_action = 0x0B;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] RemoteReset(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x0F,0x00,0x00);
}
public byte[] Zone(uint deviceAddress,byte zone, Action action)
{
if(zone<0x01 & zone>0x08)
throw new Exception("Zone value should be between 0x01 and 0x08 include");
byte m_action;
if(action == Action.Start)
m_action = 0x11;
else
m_action = 0x13;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,zone);
}
public byte[] WriteToScreen(uint deviceAddress,string text)
{
if(text.Length > 40)
text = text.Remove(40,text.Length-40);
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] m_bytes = new byte[encoding.GetByteCount(text)*8];
int i = 0;
byte m_scrPosition;
byte m_ASCIIchr;
foreach(char ch in text)
{
m_scrPosition = Convert.ToByte(i/8);
m_ASCIIchr = Convert.ToByte(ch);
Array.Copy(Message.GetMessage(deviceAddress,0x00,0x15,m_scrPosition,m_ASCIIchr),0,m_bytes,i,8);
i = i + 8;
}
return m_bytes;
}
public byte[] ClearScreen(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x17,0x00,0x00);
}
public byte[] AlarmAcknowledge(uint deviceAddress, uint alarmID)
{
if(alarmID < 1 & alarmID>8)
throw new Exception("Only 8 alarms allowed for Pelco P implementation");
return Message.GetMessage(deviceAddress,0x00,0x19,0x00,Convert.ToByte(alarmID));
}
public byte[] ZoneScan(uint deviceAddress,Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x1B;
else
m_action = 0x1D;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] Pattern(uint deviceAddress,PatternAction action)
{
byte m_action;
switch (action)
{
case PatternAction.Start:
m_action = 0x1F;
break;
case PatternAction.Stop:
m_action = 0x21;
break;
case PatternAction.Run:
m_action = 0x23;
break;
default:
m_action = 0x23;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] SetZoomLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x25,0x00,(byte)speed);
}
public byte[] SetFocusLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x27,0x00,(byte)speed);
}
#endregion
#region Base Command Set
public byte[] CameraSwitch(uint deviceAddress,Switch action)
{
byte m_action = CameraOnOff;
if(action == Switch.On)
m_action += CameraOnOff; //Maybe wrong !!!
return Message.GetMessage(deviceAddress,m_action,0x00,0x00,0x00);
}
public byte[] CameraIrisSwitch(uint deviceAddress,Iris action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraFocus(uint deviceAddress,Focus action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraZoom(uint deviceAddress,Zoom action)
{
return Message.GetMessage(deviceAddress,0x00,(byte)action,0x00,0x00);
}
public byte[] CameraTilt(uint deviceAddress,Tilt action, uint speed)
{
if(speed32)
throw new Exception("Protocol Pelco P support 32 devices only");
Address = Byte.Parse((address-1).ToString());
Data1 = data1;
Data2 = data2;
Data3 = data3;
Data4 = data4;
CheckSum = (byte)(STX ^ Address ^ Data1 ^ Data2 ^ Data3 ^ Data4 ^ ETX);
return new byte[]{STX,Address,Data1,Data2,Data3,Data4,ETX,CheckSum};
}
}
}
//}
Pelco-D (I did some update from author source code for bugs)
/*-------------------------------------------------------------------------------
* Author: Tamir Khason, 2004
* Email: tamir@khason.biz
* Web: http://www.dotnet.us/
*
* Freeware: Please do not remove this header
*
* File: P.cs
*
* Description: PELCO P Protocol Implementation dot.NET Way
* This is GPL software. Do with it as you want, but feed us back any improvements.
*
* This is a simple class to control a PELCO PTZ camera via RS422/485
* 'P' protocol. It supports all of the commands including UP, DOWN, IN, OUT, LEFT,
* RIGHT, NEAR, FAR, as well as all other extended commands.
*
* To use this, you need to put a RS232->RS422 adapter on the output
* of your desired serial port.
*
* The Pelco doesn't return ANY usefull info back, so you only really need 2-wire support
* (one way) communications out.
*
*
* Version: 1.4
* ------------------------------------------------------------------------------*/
using System;
using System.Collections;
//namespace Pelco
//{
///
/// dot.NET Implementation of Pelco P Protocol
///
public class P //: Pelco
{
private const byte STX = 0xA0;
private const byte ETX = 0xAF;
#region Pan and Tilt Commands
#region Data1
private const byte FocusFar = 0x01;
private const byte FocusNear = 0x02;
private const byte IrisOpen = 0x04;
private const byte IrisClose = 0x08;
private const byte CameraOnOff = 0x10;
private const byte AutoscanOn = 0x20;
private const byte CameraOn = 0x40;
#endregion
#region Data2
private const byte PanRight = 0x02;
private const byte PanLeft = 0x04;
private const byte TiltUp = 0x08;
private const byte TiltDown = 0x10;
private const byte ZoomTele = 0x20;
private const byte ZoomWide = 0x40;
#endregion
#region Data3
private const byte PanSpeedMin = 0x00;
private const byte PanSpeedMax = 0x40;
#endregion
#region Data4
private const byte TiltSpeedMin = 0x00;
private const byte TiltSpeedMax = 0x3F;
#endregion
#endregion
#region Enums
public enum PresetAction {Set,Clear,Goto}
public enum PatternAction {Start,Stop,Run}
public enum Action {Start,Stop}
public enum LensSpeed {Low=0x00,Medium=0x01,High=0x02,Turbo=0x03}
public enum Pan {Left = PanLeft,Right = PanRight}
public enum Tilt {Up = TiltUp,Down = TiltDown}
public enum Iris {Open = IrisOpen,Close = IrisClose}
public enum Zoom {Wide = ZoomWide,Tele = ZoomTele}
public enum Switch {On,Off}
public enum Focus {Near = FocusNear,Far = FocusFar}
#endregion
#region Extended Command Set
public byte[] Preset(uint deviceAddress, byte preset, PresetAction action)
{
byte m_action;
switch (action)
{
case PresetAction.Set:
m_action = 0x03;
break;
case PresetAction.Clear:
m_action = 0x05;
break;
case PresetAction.Goto:
m_action = 0x07;
break;
default:
m_action = 0x03;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,preset);
}
public byte[] Flip(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x21);
}
public byte[] ZeroPanPosition(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x22);
}
public byte[] AutoScan(uint deviceAddress, Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x09;
else
m_action = 0x0B;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] RemoteReset(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x0F,0x00,0x00);
}
public byte[] Zone(uint deviceAddress,byte zone, Action action)
{
if(zone<0x01 & zone>0x08)
throw new Exception("Zone value should be between 0x01 and 0x08 include");
byte m_action;
if(action == Action.Start)
m_action = 0x11;
else
m_action = 0x13;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,zone);
}
public byte[] WriteToScreen(uint deviceAddress,string text)
{
if(text.Length > 40)
text = text.Remove(40,text.Length-40);
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] m_bytes = new byte[encoding.GetByteCount(text)*8];
int i = 0;
byte m_scrPosition;
byte m_ASCIIchr;
foreach(char ch in text)
{
m_scrPosition = Convert.ToByte(i/8);
m_ASCIIchr = Convert.ToByte(ch);
Array.Copy(Message.GetMessage(deviceAddress,0x00,0x15,m_scrPosition,m_ASCIIchr),0,m_bytes,i,8);
i = i + 8;
}
return m_bytes;
}
public byte[] ClearScreen(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x17,0x00,0x00);
}
public byte[] AlarmAcknowledge(uint deviceAddress, uint alarmID)
{
if(alarmID < 1 & alarmID>8)
throw new Exception("Only 8 alarms allowed for Pelco P implementation");
return Message.GetMessage(deviceAddress,0x00,0x19,0x00,Convert.ToByte(alarmID));
}
public byte[] ZoneScan(uint deviceAddress,Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x1B;
else
m_action = 0x1D;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] Pattern(uint deviceAddress,PatternAction action)
{
byte m_action;
switch (action)
{
case PatternAction.Start:
m_action = 0x1F;
break;
case PatternAction.Stop:
m_action = 0x21;
break;
case PatternAction.Run:
m_action = 0x23;
break;
default:
m_action = 0x23;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] SetZoomLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x25,0x00,(byte)speed);
}
public byte[] SetFocusLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x27,0x00,(byte)speed);
}
#endregion
#region Base Command Set
public byte[] CameraSwitch(uint deviceAddress,Switch action)
{
byte m_action = CameraOnOff;
if(action == Switch.On)
m_action += CameraOnOff; //Maybe wrong !!!
return Message.GetMessage(deviceAddress,m_action,0x00,0x00,0x00);
}
public byte[] CameraIrisSwitch(uint deviceAddress,Iris action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraFocus(uint deviceAddress,Focus action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraZoom(uint deviceAddress,Zoom action)
{
return Message.GetMessage(deviceAddress,0x00,(byte)action,0x00,0x00);
}
public byte[] CameraTilt(uint deviceAddress,Tilt action, uint speed)
{
if(speed32)
throw new Exception("Protocol Pelco P support 32 devices only");
Address = Byte.Parse((address-1).ToString());
Data1 = data1;
Data2 = data2;
Data3 = data3;
Data4 = data4;
CheckSum = (byte)(STX ^ Address ^ Data1 ^ Data2 ^ Data3 ^ Data4 ^ ETX);
return new byte[]{STX,Address,Data1,Data2,Data3,Data4,ETX,CheckSum};
}
}
}
//}
Pelco-P
/*-------------------------------------------------------------------------------
* Author: Tamir Khason, 2004
* Email: tamir@khason.biz
* Web: http://www.dotnet.us/
*
* Freeware: Please do not remove this header
*
* File: P.cs
*
* Description: PELCO P Protocol Implementation dot.NET Way
* This is GPL software. Do with it as you want, but feed us back any improvements.
*
* This is a simple class to control a PELCO PTZ camera via RS422/485
* 'P' protocol. It supports all of the commands including UP, DOWN, IN, OUT, LEFT,
* RIGHT, NEAR, FAR, as well as all other extended commands.
*
* To use this, you need to put a RS232->RS422 adapter on the output
* of your desired serial port.
*
* The Pelco doesn't return ANY usefull info back, so you only really need 2-wire support
* (one way) communications out.
*
*
* Version: 1.4
* ------------------------------------------------------------------------------*/
using System;
using System.Collections;
//namespace Pelco
//{
///
/// dot.NET Implementation of Pelco P Protocol
///
public class P //: Pelco
{
private const byte STX = 0xA0;
private const byte ETX = 0xAF;
#region Pan and Tilt Commands
#region Data1
private const byte FocusFar = 0x01;
private const byte FocusNear = 0x02;
private const byte IrisOpen = 0x04;
private const byte IrisClose = 0x08;
private const byte CameraOnOff = 0x10;
private const byte AutoscanOn = 0x20;
private const byte CameraOn = 0x40;
#endregion
#region Data2
private const byte PanRight = 0x02;
private const byte PanLeft = 0x04;
private const byte TiltUp = 0x08;
private const byte TiltDown = 0x10;
private const byte ZoomTele = 0x20;
private const byte ZoomWide = 0x40;
#endregion
#region Data3
private const byte PanSpeedMin = 0x00;
private const byte PanSpeedMax = 0x40;
#endregion
#region Data4
private const byte TiltSpeedMin = 0x00;
private const byte TiltSpeedMax = 0x3F;
#endregion
#endregion
#region Enums
public enum PresetAction {Set,Clear,Goto}
public enum PatternAction {Start,Stop,Run}
public enum Action {Start,Stop}
public enum LensSpeed {Low=0x00,Medium=0x01,High=0x02,Turbo=0x03}
public enum Pan {Left = PanLeft,Right = PanRight}
public enum Tilt {Up = TiltUp,Down = TiltDown}
public enum Iris {Open = IrisOpen,Close = IrisClose}
public enum Zoom {Wide = ZoomWide,Tele = ZoomTele}
public enum Switch {On,Off}
public enum Focus {Near = FocusNear,Far = FocusFar}
#endregion
#region Extended Command Set
public byte[] Preset(uint deviceAddress, byte preset, PresetAction action)
{
byte m_action;
switch (action)
{
case PresetAction.Set:
m_action = 0x03;
break;
case PresetAction.Clear:
m_action = 0x05;
break;
case PresetAction.Goto:
m_action = 0x07;
break;
default:
m_action = 0x03;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,preset);
}
public byte[] Flip(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x21);
}
public byte[] ZeroPanPosition(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x22);
}
public byte[] AutoScan(uint deviceAddress, Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x09;
else
m_action = 0x0B;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] RemoteReset(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x0F,0x00,0x00);
}
public byte[] Zone(uint deviceAddress,byte zone, Action action)
{
if(zone<0x01 & zone>0x08)
throw new Exception("Zone value should be between 0x01 and 0x08 include");
byte m_action;
if(action == Action.Start)
m_action = 0x11;
else
m_action = 0x13;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,zone);
}
public byte[] WriteToScreen(uint deviceAddress,string text)
{
if(text.Length > 40)
text = text.Remove(40,text.Length-40);
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] m_bytes = new byte[encoding.GetByteCount(text)*8];
int i = 0;
byte m_scrPosition;
byte m_ASCIIchr;
foreach(char ch in text)
{
m_scrPosition = Convert.ToByte(i/8);
m_ASCIIchr = Convert.ToByte(ch);
Array.Copy(Message.GetMessage(deviceAddress,0x00,0x15,m_scrPosition,m_ASCIIchr),0,m_bytes,i,8);
i = i + 8;
}
return m_bytes;
}
public byte[] ClearScreen(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x17,0x00,0x00);
}
public byte[] AlarmAcknowledge(uint deviceAddress, uint alarmID)
{
if(alarmID < 1 & alarmID>8)
throw new Exception("Only 8 alarms allowed for Pelco P implementation");
return Message.GetMessage(deviceAddress,0x00,0x19,0x00,Convert.ToByte(alarmID));
}
public byte[] ZoneScan(uint deviceAddress,Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x1B;
else
m_action = 0x1D;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] Pattern(uint deviceAddress,PatternAction action)
{
byte m_action;
switch (action)
{
case PatternAction.Start:
m_action = 0x1F;
break;
case PatternAction.Stop:
m_action = 0x21;
break;
case PatternAction.Run:
m_action = 0x23;
break;
default:
m_action = 0x23;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] SetZoomLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x25,0x00,(byte)speed);
}
public byte[] SetFocusLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x27,0x00,(byte)speed);
}
#endregion
#region Base Command Set
public byte[] CameraSwitch(uint deviceAddress,Switch action)
{
byte m_action = CameraOnOff;
if(action == Switch.On)
m_action += CameraOnOff; //Maybe wrong !!!
return Message.GetMessage(deviceAddress,m_action,0x00,0x00,0x00);
}
public byte[] CameraIrisSwitch(uint deviceAddress,Iris action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraFocus(uint deviceAddress,Focus action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraZoom(uint deviceAddress,Zoom action)
{
return Message.GetMessage(deviceAddress,0x00,(byte)action,0x00,0x00);
}
public byte[] CameraTilt(uint deviceAddress,Tilt action, uint speed)
{
if(speed
throw new Exception("Protocol Pelco P support 32 devices only");
Address = Byte.Parse((address-1).ToString());
Data1 = data1;
Data2 = data2;
Data3 = data3;
Data4 = data4;
CheckSum = (byte)(STX ^ Address ^ Data1 ^ Data2 ^ Data3 ^ Data4 ^ ETX);
return new byte[]{STX,Address,Data1,Data2,Data3,Data4,ETX,CheckSum};
}
}
}
//}
Pelco-D (I did some update from author source code for bugs)
/*-------------------------------------------------------------------------------
* Author: Tamir Khason, 2004
* Email: tamir@khason.biz
* Web: http://www.dotnet.us/
*
* Freeware: Please do not remove this header
*
* File: P.cs
*
* Description: PELCO P Protocol Implementation dot.NET Way
* This is GPL software. Do with it as you want, but feed us back any improvements.
*
* This is a simple class to control a PELCO PTZ camera via RS422/485
* 'P' protocol. It supports all of the commands including UP, DOWN, IN, OUT, LEFT,
* RIGHT, NEAR, FAR, as well as all other extended commands.
*
* To use this, you need to put a RS232->RS422 adapter on the output
* of your desired serial port.
*
* The Pelco doesn't return ANY usefull info back, so you only really need 2-wire support
* (one way) communications out.
*
*
* Version: 1.4
* ------------------------------------------------------------------------------*/
using System;
using System.Collections;
//namespace Pelco
//{
///
/// dot.NET Implementation of Pelco P Protocol
///
public class P //: Pelco
{
private const byte STX = 0xA0;
private const byte ETX = 0xAF;
#region Pan and Tilt Commands
#region Data1
private const byte FocusFar = 0x01;
private const byte FocusNear = 0x02;
private const byte IrisOpen = 0x04;
private const byte IrisClose = 0x08;
private const byte CameraOnOff = 0x10;
private const byte AutoscanOn = 0x20;
private const byte CameraOn = 0x40;
#endregion
#region Data2
private const byte PanRight = 0x02;
private const byte PanLeft = 0x04;
private const byte TiltUp = 0x08;
private const byte TiltDown = 0x10;
private const byte ZoomTele = 0x20;
private const byte ZoomWide = 0x40;
#endregion
#region Data3
private const byte PanSpeedMin = 0x00;
private const byte PanSpeedMax = 0x40;
#endregion
#region Data4
private const byte TiltSpeedMin = 0x00;
private const byte TiltSpeedMax = 0x3F;
#endregion
#endregion
#region Enums
public enum PresetAction {Set,Clear,Goto}
public enum PatternAction {Start,Stop,Run}
public enum Action {Start,Stop}
public enum LensSpeed {Low=0x00,Medium=0x01,High=0x02,Turbo=0x03}
public enum Pan {Left = PanLeft,Right = PanRight}
public enum Tilt {Up = TiltUp,Down = TiltDown}
public enum Iris {Open = IrisOpen,Close = IrisClose}
public enum Zoom {Wide = ZoomWide,Tele = ZoomTele}
public enum Switch {On,Off}
public enum Focus {Near = FocusNear,Far = FocusFar}
#endregion
#region Extended Command Set
public byte[] Preset(uint deviceAddress, byte preset, PresetAction action)
{
byte m_action;
switch (action)
{
case PresetAction.Set:
m_action = 0x03;
break;
case PresetAction.Clear:
m_action = 0x05;
break;
case PresetAction.Goto:
m_action = 0x07;
break;
default:
m_action = 0x03;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,preset);
}
public byte[] Flip(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x21);
}
public byte[] ZeroPanPosition(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x07,0x00,0x22);
}
public byte[] AutoScan(uint deviceAddress, Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x09;
else
m_action = 0x0B;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] RemoteReset(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x0F,0x00,0x00);
}
public byte[] Zone(uint deviceAddress,byte zone, Action action)
{
if(zone<0x01 & zone>0x08)
throw new Exception("Zone value should be between 0x01 and 0x08 include");
byte m_action;
if(action == Action.Start)
m_action = 0x11;
else
m_action = 0x13;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,zone);
}
public byte[] WriteToScreen(uint deviceAddress,string text)
{
if(text.Length > 40)
text = text.Remove(40,text.Length-40);
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] m_bytes = new byte[encoding.GetByteCount(text)*8];
int i = 0;
byte m_scrPosition;
byte m_ASCIIchr;
foreach(char ch in text)
{
m_scrPosition = Convert.ToByte(i/8);
m_ASCIIchr = Convert.ToByte(ch);
Array.Copy(Message.GetMessage(deviceAddress,0x00,0x15,m_scrPosition,m_ASCIIchr),0,m_bytes,i,8);
i = i + 8;
}
return m_bytes;
}
public byte[] ClearScreen(uint deviceAddress)
{
return Message.GetMessage(deviceAddress,0x00,0x17,0x00,0x00);
}
public byte[] AlarmAcknowledge(uint deviceAddress, uint alarmID)
{
if(alarmID < 1 & alarmID>8)
throw new Exception("Only 8 alarms allowed for Pelco P implementation");
return Message.GetMessage(deviceAddress,0x00,0x19,0x00,Convert.ToByte(alarmID));
}
public byte[] ZoneScan(uint deviceAddress,Action action)
{
byte m_action;
if(action == Action.Start)
m_action = 0x1B;
else
m_action = 0x1D;
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] Pattern(uint deviceAddress,PatternAction action)
{
byte m_action;
switch (action)
{
case PatternAction.Start:
m_action = 0x1F;
break;
case PatternAction.Stop:
m_action = 0x21;
break;
case PatternAction.Run:
m_action = 0x23;
break;
default:
m_action = 0x23;
break;
}
return Message.GetMessage(deviceAddress,0x00,m_action,0x00,0x00);
}
public byte[] SetZoomLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x25,0x00,(byte)speed);
}
public byte[] SetFocusLensSpeed(uint deviceAddress, LensSpeed speed)
{
return Message.GetMessage(deviceAddress,0x00,0x27,0x00,(byte)speed);
}
#endregion
#region Base Command Set
public byte[] CameraSwitch(uint deviceAddress,Switch action)
{
byte m_action = CameraOnOff;
if(action == Switch.On)
m_action += CameraOnOff; //Maybe wrong !!!
return Message.GetMessage(deviceAddress,m_action,0x00,0x00,0x00);
}
public byte[] CameraIrisSwitch(uint deviceAddress,Iris action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraFocus(uint deviceAddress,Focus action)
{
return Message.GetMessage(deviceAddress,(byte)action,0x00,0x00,0x00);
}
public byte[] CameraZoom(uint deviceAddress,Zoom action)
{
return Message.GetMessage(deviceAddress,0x00,(byte)action,0x00,0x00);
}
public byte[] CameraTilt(uint deviceAddress,Tilt action, uint speed)
{
if(speed
throw new Exception("Protocol Pelco P support 32 devices only");
Address = Byte.Parse((address-1).ToString());
Data1 = data1;
Data2 = data2;
Data3 = data3;
Data4 = data4;
CheckSum = (byte)(STX ^ Address ^ Data1 ^ Data2 ^ Data3 ^ Data4 ^ ETX);
return new byte[]{STX,Address,Data1,Data2,Data3,Data4,ETX,CheckSum};
}
}
}
//}
Tuesday, July 26, 2011
CyanogenMod cannot download google market apps
Platform: CyanogenMod 7 (Android)
Error: Trying to install market apps, it starts downloading for a second or so and then stops. It happen on large app (more than 5Mb) files.
Reason :
To download an app from google market, android required a cache.This cache folder is located in /cache partition (it's called /cache/download).
But this partition (with a size of about 40Mb on HTC Desire) contains also others caches, notably the dalvik-cache(used to accelerate the boot of android) which has a size of...35Mb !
That why "big" apps can't be downloaded using the market but small ones can be downloaded without any issues.
This also explain the "not enough space" message in logs which does not refer to the internal or external memory but to the space of /cache/download folder.
Concerning S2E, it's only works if your sdcard is mounted under /sd-ext. For users mounted on /sdcard, another solution is to create a symlink of /cache/download which point to a folder in your sdcard.
Solution:
To clarify for anyone who isn't quite sure how to do this, enter these commands in the terminal emulator:
mkdir /mnt/sdcard/market-download-cache su cd /cache mv download download.bak ln -s /mnt/sdcard/market-download-cache download ls -ahl .
the last step (ls -ahl .) is intended to verify that /cache/download points to /mnt/sdcard/market-download-cache; there should be an entry that should look somewhat like "lrwxrwxrwx 1 root root 33 Apr 14 03:35 download -> /mnt/sdcard/market-download-cache".
Thursday, November 18, 2010
MSSQL: the process could not execute 'sp_replcmds'
Platform:
Microsoft SQL server
Error:
While replications, the Log Reader Agent status shown "the process could not execute 'sp_replcmds'...
Solution:
Change database owner to sa.
Step:
Microsoft SQL server
Error:
While replications, the Log Reader Agent status shown "the process could not execute 'sp_replcmds'...
Solution:
Change database owner to sa.
Step:
- Select "Databases", open "Object Explorer Details"(shortcut F7), you can see the current owner for every database.
- Change the owner to sa as script below:
- sp_changedbowner '
' - Repeat step 1, click refresh button to check the new database owner.
- Reinitialize the publications by click "Reinitialize All Subscriptions" .
Wednesday, June 2, 2010
How to empty Trash in Ubuntu (UNR)
Tested in Ubuntu Netbook Remix 10.04
Two ways to empty trash
1. Complete it manually in Terminal
sudo rm -rf /home//.local/share/Trash/files/*
2. In "Files & folders", click any folder icon to open File browser. Click "Go" in the toolbar, then select Trash. Simply click the "Empty Trash", your Trash folder will be empty.
Two ways to empty trash
1. Complete it manually in Terminal
sudo rm -rf /home//.local/share/Trash/files/*
2. In "Files & folders", click any folder icon to open File browser. Click "Go" in the toolbar, then select Trash. Simply click the "Empty Trash", your Trash folder will be empty.
Friday, May 14, 2010
Mobile Broadband USB modem in Ubuntu
1. Open a terminal
2. Install udev-extras from the standard Ubuntu repositories:
sudo apt-get update && sudo apt-get install udev-extras
or
sudo apt-get update && sudo apt-get install udev
3. Add a custom udev rule for the Huawei E1550 by typing this line:
echo 'SUBSYSTEM=="usb", SYSFS{idProduct}=="1446", SYSFS{idVendor}=="12d1", RUN+="/lib/udev/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"' | sudo tee /etc/udev/rules.d/45-huawei1550.rules
4. Configure the Mobile Broadband on Network Manager. (right mouse the Network icon near the volume icon).
5. Select Mobile Boardband -> Add
6. After added, restart the pc.
7. Cheers...
2. Install udev-extras from the standard Ubuntu repositories:
sudo apt-get update && sudo apt-get install udev-extras
or
sudo apt-get update && sudo apt-get install udev
3. Add a custom udev rule for the Huawei E1550 by typing this line:
echo 'SUBSYSTEM=="usb", SYSFS{idProduct}=="1446", SYSFS{idVendor}=="12d1", RUN+="/lib/udev/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"' | sudo tee /etc/udev/rules.d/45-huawei1550.rules
4. Configure the Mobile Broadband on Network Manager. (right mouse the Network icon near the volume icon).
5. Select Mobile Boardband -> Add
6. After added, restart the pc.
7. Cheers...
Thursday, April 8, 2010
Change the font
MILWAUKEE – Here's a way you might save $20 this year: Change the font in the documents you print.
Because different fonts require different amounts of ink to print, you could be buying new printer cartridges less often if you wrote in, say, Century Gothic rather than Arial. Schools and businesses could save thousands of dollars with font changes.
Data on the subject from Printer.com, a Dutch company that evaluates printer attributes, persuaded the University of Wisconsin-Green Bay to make a switch. Diane Blohowiak, coordinator of information-technology user support, has asked faculty and staff to use Century Gothic for all printed documents. The school also plans to change its e-mail system so it uses Century Gothic.
"The feedback we've gotten so far has been positive," she said. "Century Gothic is very readable."
The school of 6,500 students spends about $100,000 per year on ink and toner cartridges. Although students and staff can change the default font to something more ink-intensive, Blohowiak said the university expects to save $5,000 to $10,000 per year with the font switch.
When Printer.com tested popular fonts for their ink-friendly ways, Century Gothic and Times New Roman topped the list. Calibri, Verdana, Arial and Sans Serif were next, followed by Trebuchet, Tahoma and Franklin Gothic Medium. Century Gothic uses about 30 percent less ink than Arial.
The amount of ink a font drains is mainly driven by the thickness of its lines. A font with "narrow" or "light" in its name is usually better than its "bold" or "black" counterpart, said Thom Brown, an ink researcher at Hewlett-Packard Co., the world's top maker of printers.
Also, serif fonts — those with short horizontal lines at the top and bottom of characters — tend to use thinner lines and thus less ink than a "sans serif" counterpart.
But while using less ink at home can help you buy roughly one fewer printer cartridge each year, it's not necessarily better for the environment.
That's because some fonts that use less ink, including Century Gothic, are also wider. A document that's one page in Arial could extend to a second page if printed in Century Gothic. Blohowiak said her research suggests that ink comprises the main cost of a printout, but the environmental costs of paper are probably higher.
"Maybe the individual characters use less ink, but if you're using more paper, that's not so green, is it?" said Allan Haley, director of "words and letters" at Monotype Imaging Inc. in Woburn, Mass., which developed Century Gothic.
Also, Century Gothic was designed for limited blocks of text such as titles and headlines, not for full documents, said Haley, who describes fonts as his "children." Despite Printer.com's research and UW-Green Bay's experience, Haley said he still recommends Times New Roman or Arial for their readability.
The standard advice for trimming printing expenses still applies: Print in "draft mode," if you can. Use both sides of a page and do a print preview to make sure you're not printing pages with useless text such as a copyright line. Using an ink-saving font is just one more technique to consider.
And the greenest way to save on ink is not to print at all.
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
"We're trying to move the threshold of when people hit the print button," he said.
By DINESH RAMDE, Associated Press Writer Dinesh Ramde, Associated Press Writer
Times New Roman
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
Cambria
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
Cambria
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
Because different fonts require different amounts of ink to print, you could be buying new printer cartridges less often if you wrote in, say, Century Gothic rather than Arial. Schools and businesses could save thousands of dollars with font changes.
Data on the subject from Printer.com, a Dutch company that evaluates printer attributes, persuaded the University of Wisconsin-Green Bay to make a switch. Diane Blohowiak, coordinator of information-technology user support, has asked faculty and staff to use Century Gothic for all printed documents. The school also plans to change its e-mail system so it uses Century Gothic.
"The feedback we've gotten so far has been positive," she said. "Century Gothic is very readable."
The school of 6,500 students spends about $100,000 per year on ink and toner cartridges. Although students and staff can change the default font to something more ink-intensive, Blohowiak said the university expects to save $5,000 to $10,000 per year with the font switch.
When Printer.com tested popular fonts for their ink-friendly ways, Century Gothic and Times New Roman topped the list. Calibri, Verdana, Arial and Sans Serif were next, followed by Trebuchet, Tahoma and Franklin Gothic Medium. Century Gothic uses about 30 percent less ink than Arial.
The amount of ink a font drains is mainly driven by the thickness of its lines. A font with "narrow" or "light" in its name is usually better than its "bold" or "black" counterpart, said Thom Brown, an ink researcher at Hewlett-Packard Co., the world's top maker of printers.
Also, serif fonts — those with short horizontal lines at the top and bottom of characters — tend to use thinner lines and thus less ink than a "sans serif" counterpart.
But while using less ink at home can help you buy roughly one fewer printer cartridge each year, it's not necessarily better for the environment.
That's because some fonts that use less ink, including Century Gothic, are also wider. A document that's one page in Arial could extend to a second page if printed in Century Gothic. Blohowiak said her research suggests that ink comprises the main cost of a printout, but the environmental costs of paper are probably higher.
"Maybe the individual characters use less ink, but if you're using more paper, that's not so green, is it?" said Allan Haley, director of "words and letters" at Monotype Imaging Inc. in Woburn, Mass., which developed Century Gothic.
Also, Century Gothic was designed for limited blocks of text such as titles and headlines, not for full documents, said Haley, who describes fonts as his "children." Despite Printer.com's research and UW-Green Bay's experience, Haley said he still recommends Times New Roman or Arial for their readability.
The standard advice for trimming printing expenses still applies: Print in "draft mode," if you can. Use both sides of a page and do a print preview to make sure you're not printing pages with useless text such as a copyright line. Using an ink-saving font is just one more technique to consider.
And the greenest way to save on ink is not to print at all.
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
"We're trying to move the threshold of when people hit the print button," he said.
By DINESH RAMDE, Associated Press Writer Dinesh Ramde, Associated Press Writer
Times New Roman
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
That's the philosophy Microsoft Corp. said it uses in deciding which fonts to include in its Outlook and Word applications. The more pleasing a font looks on the screen, the less tempted someone will be to print, said Simon Daniels, a program manager for Microsoft's typography group.
That's why the company changed its defaults in Office 2007 from Arial and Times New Roman to Calibri and Cambria, he said.
Subscribe to:
Comments (Atom)
