教你如何在虚拟机Ubuntu下编译csipsimple
转载请注明出处:http://blog.csdn.net/jingyuansuifeng/article/details/8120523
首先是官方文档:http://code.google.com/p/csipsimple/wiki/HowToBuild
1. 安装好VMware
2. 下载CSipSimple-CompilerVM.vmdk,这是官方编译好的环境,可以直接导入至虚拟机。下载地址:https://docs.google.com/file/d/0ByFooYVveHXdYVV6eVhaUElWaGM/edit?pli=1
3. 启动VMware导入以上vmdk文件
3.1 新建虚拟机
注意:上图第一个是你虚拟机的名字,第二个是虚拟机存放的位置,你都可以随便设这,但是一定要自己记得。
上图分配内存一般根据自己机器情况设定,我选的是默认
上图是网略配置,我选的是默认
上图选择已经存在的虚拟机,也就你前面下载好的CSipSimple-CompilerVM.vmdk。
选择你下载好的虚拟机。使用已存在的格式
好了,至此虚拟环境就准备好了,下面我们看看里面都有哪些东西。
4. 编译Csipsimple
看到桌面有一个文件Before doing anything else PLEASE read this document first!.txt
原文如下:
Welcometo the Virtual Machine v0.1 for compiling cSipSimple.
#Disclaimer:We do not guarantee that this machine does everything correctly.
#Description
Thismachine can compile cSipSimple incl. the native libaries.
It isbased upon the description http://code.google.com/p/csipsimple/wiki/HowToBuild
#Get started
1. Read the HowToBuild-Pagehttp://code.google.com/p/csipsimple/wiki/HowToBuild
2. The project source is checkout to the desktop(/home/user/Desktop).
3. Before compile get the latest version from the repository:"svn up" for ActionBarSherlock and cSipSimple)
4. Check Eclipse plugins for updates: OpenEclipse->Help->Check for Updates and install all updates
5. Update NDK and SDK: Open Eclipse DDMS and download latestandroid version, latest NDK and SDK
6. Rebuild the native libraries: make update
7. Open Eclipse and check that you are compiling against thecorrect Android API (often the latest)
8. Try to run cSipSimple in emulator
9. Congratulation!
#Ifsomething compilation fails>
1. Checkthat the setup of the virtual machine is similar as descripted byhttp://code.google.com/p/csipsimple/wiki/HowToBuild
2. Checkthat you did nothing wrong.
3. Checkagain.
4. Check thegoogle developer group: http://groups.google.com/group/csipsimple-dev/
5. Checkthe google developer group carefully again
6.Compile a USEFUL, i.e. descriptive and complete report, and send it to thedeveloper group incl. a useful and descriptive title
7.(Optional) Post the solution if found
Technicaldetails:
* Ubuntu12.04 32bit
* AndroidNDK 8
* AndroidSDK 20
* Eclipsewith subclipse
* Use sudo to get root; password is identical to theusername
所以我们就按照他的步骤来,这时候要淡定
注意:这里我没有进行更新
然后就是:make (我也没有用 make update),这边更慢,大家一定要淡定。。。63M的东西要下载90分钟真心伤不起,下面有惊喜!
所以这里建议大家事先下载好SILK_SDK_SRC_v1.0.8.zip把文件放在CSipSimple/jni/silk下
下载地址:http://developer.skype.com/silk/SILK_SDK_SRC_v1.0.8.zip
然后修改CSipSimple/jni/silk下的makefile去掉
@wget http://developer.skype.com/silk/SILK_SDK_SRC_v1.0.8.zip;\
然后再运行make ,就会看到下面的画面
如果这边还是嫌慢的话,直接把解压好的SILK_SDK_SRC_v1.0.8复制到jni/opus目录下。
然后你就开始慢慢等吧。。。。。。
最后会出现
不过有两个错误,不知道为什么,先记着不去管它
打开eclipse
编译的时候有点慢,要淡定。。。
这时候要刷新下工程,然后clean下
现在就没有错误了
然后run一下,就看到效果了,这里我实在真机上测试的
OK,到此结束,由于我没有搭建服务器,所以通话怎么样就看你们了,基本的编译就那么多。至于以上两个error问题,有兴趣的人可以按照Before doing anything else PLEASE read this document first!.txt这个文档来,看看还有没有错误。
附录:
1. 解決Linux下Android开发真机调试设备不被识别问题
http://my.oschina.net/u/591065/blog/68888
2. VMware虚拟机下使linux全屏的方法
1、点击“view”——然后将Autofit window这个选项勾选。(一般版本高的VMware虚拟机都会默认该设置)
2、该步骤是关键,具体的操作为:点击“VM”——选中“installvmware-tools”这个选项即可。
接下来的操作都是在虚拟机中的linux中进行
(1)打开linux的cdrom看是否有VMware Tools 的文件,如果有则说明“install VMware tools”成功了
(2)挂载cdrom到/mnt/cdrom目录下,具体命令为:mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom www.2cto.com
(3)解压cdrom中的文件: tar zxpf /mnt/cdrom/VMwareTools-<x.x.x>-<yyyy>.tar.gz
(4)进入tmp目录找到解压后的文件夹并进入:cd vmware-tools-distrib
(5)执行命令:./vmware-install.pl
然后根据系统提示,选择相关的选项即可。大概5分钟左右即可加载成功。
加载成功之后还须执行以下命令:
/etc/init.d/network stop
rmmod vmxnet
modprobe vmxnet
/etc/init.d/network start
一切操作做完后重启系统即可:reboot
下次开机即可看到自己的linux系统可以全屏了
1楼jingyuansuifeng4天前 19:56那么多人看,就是没得评论的
mstpscap.c这个文件主要实现从串口上抓取MS/TP协议上的packet功能。测试时的格式为:mstsnap [serial] [baud] [network]
默认参数是串口/dev/ttyUSB0、波特率是38400,eth0。
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
/* OS specific include*/
#include "net.h"
#include "timer.h"
/* local includes */
#include "bytes.h"
#include "rs485.h"
#include "crc.h"
#include "mstp.h"
#include "dlmstp.h"
#include "mstptext.h"
#include "bacint.h"
/** @file linux/mstpsnap.c Example application testing BACnet MS/TP on Linux. */
#ifndef max
#define max(a,b) (((a) >(b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
/* local port data - shared with RS-485 */
static volatile struct mstp_port_struct_t MSTP_Port;
/* buffers needed by mstp port struct */
static uint8_t RxBuffer[MAX_MPDU];
static uint8_t TxBuffer[MAX_MPDU];
static uint16_t Timer_Silence(
void)
{
uint32_t delta_time = 0;
delta_time = timer_milliseconds(TIMER_SILENCE);
if (delta_time > 0xFFFF) {
delta_time = 0xFFFF;
}
return (uint16_t) delta_time;
}
static void Timer_Silence_Reset(
void)
{
timer_reset(TIMER_SILENCE);
}
/* functions used by the MS/TP state machine to put or get data */
uint16_t MSTP_Put_Receive(
volatile struct mstp_port_struct_t *mstp_port)
{
(void) mstp_port;
return 0;
}
/* for the MS/TP state machine to use for getting data to send */
/* Return: amount of PDU data */
uint16_t MSTP_Get_Send(
volatile struct mstp_port_struct_t * mstp_port,
unsigned timeout)
{ /* milliseconds to wait for a packet */
(void) mstp_port;
(void) timeout;
return 0;
}
uint16_t MSTP_Get_Reply(
volatile struct mstp_port_struct_t * mstp_port,
unsigned timeout)
{ /* milliseconds to wait for a packet */
(void) mstp_port;
(void) timeout;
return 0;
}
static int network_init(
const char *name,
int protocol)
{
/* check to see if we are being run as root */
if (getuid() != 0) { //函数返回一个调用程序的真实用户ID,一般来说,这个函数都是会调用成功的。getuid=0表示root用户
fprintf(stderr, "Requires root priveleges.\n");
return -1;
}
int sockfd = socket(PF_PACKET, SOCK_RAW, htons(protocol)); //得到原始的IP包,htons得到网络字节序(大端模式)网络上统一使用大端模式传输
if (sockfd == -1) {
perror("Unable to create socket");
return sockfd;
}
struct ifreq ifr; //获取IP地址和MAC地址
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, strlen(name));
if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) { //获取并打印网卡地址
perror("Unable to get interface index");
return -1;
}
struct sockaddr_ll sll; //本地地址
memset(&sll, 0, sizeof(sll));
sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons(protocol);
if (bind(sockfd, (struct sockaddr *) &sll, sizeof(sll)) == -1) { //绑定套接字
perror("Unable to bind socket");
return -1;
}
return sockfd;
}
static void snap_received_packet(
volatile struct mstp_port_struct_t *mstp_port,
int sockfd)
{
uint16_t mtu_len = 0; /* number of octets of packet saved in file */
unsigned i = 0; /* counter */
static uint8_t mtu[1500] = { 0 }; //考虑到物理层实现等原因,以太网一帧的长度一般要求小于1500字节
uint16_t max_data = 0;
mtu[0] = 0;
mtu[1] = 0;
mtu[2] = 0;
mtu[3] = 0;
mtu[4] = 0;
mtu[5] = mstp_port->DestinationAddress;
mtu[6] = 0;
mtu[7] = 0;
mtu[8] = 0;
mtu[9] = 0;
mtu[10] = 0;
mtu[11] = mstp_port->SourceAddress;
/* length - 12, 13 */
mtu[14] = 0xaa; /* DSAP for SNAP */
mtu[15] = 0xaa; /* SSAP for SNAP */
mtu[16] = 0x03; /* Control Field for SNAP */
mtu[17] = 0x00; /* Organization Code: Cimetrics */
mtu[18] = 0x10; /* Organization Code: Cimetrics */
mtu[19] = 0x90; /* Organization Code: Cimetrics */
mtu[20] = 0x00; /* Protocol ID */
mtu[21] = 0x01; /* Protocol ID */
mtu[22] = 0x00; /* delta time */
mtu[23] = 0x00; /* delta time */
mtu[24] = 0x80; /* unknown byte */
mtu[25] = mstp_port->FrameType;
mtu[26] = mstp_port->DestinationAddress;
mtu[27] = mstp_port->SourceAddress;
mtu[28] = HI_BYTE(mstp_port->DataLength);
mtu[29] = LO_BYTE(mstp_port->DataLength);
mtu[30] = mstp_port->HeaderCRCActual;
mtu_len = 31;
if (mstp_port->DataLength) { //分别往里面存放从输入缓存器中的数据、DataCRCActual(先高位后低位顺序)
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
for (i = 0; i < max_data; i++) {
mtu[31 + i] = mstp_port->InputBuffer[i];
}
mtu[31 + max_data] = mstp_port->DataCRCActualMSB;
mtu[31 + max_data + 1] = mstp_port->DataCRCActualLSB;
mtu_len += (max_data + 2);
}
/* Ethernet length is data only - not address or length bytes */
encode_unsigned16(&mtu[12], mtu_len - 14); //给整数类型编码
(void) write(sockfd, &mtu[0], mtu_len);
}
static void cleanup(
void)
{
}
#if (!defined(_WIN32))
static void sig_int(
int signo)
{
(void) signo;
cleanup();
exit(0);
}
void signal_init(
void)
{
signal(SIGINT, sig_int);
signal(SIGHUP, sig_int);
signal(SIGTERM, sig_int);
}
#endif
/* simple test to packetize the data and print it */
int main(int argc,char *argv[]) //main函数实现在Linux 终端运行root#mstpsnap /dev/tty/USB0 38400 eth0
{
volatile struct mstp_port_struct_t *mstp_port;
long my_baud = 38400;
uint32_t packet_count = 0;
int sockfd = -1;
char *my_interface = "eth0";
/* mimic our pointer in the state machine */
mstp_port = &MSTP_Port;
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
printf("mstsnap [serial] [baud] [network]\r\n"
"Captures MS/TP packets from a serial interface\r\n"
"and sends them to a network interface using SNAP \r\n"
"protocol packets (mimics Cimetrics U+4 packet).\r\n" "\r\n"
"Command line options:\r\n" "[serial] - serial interface.\r\n"
" defaults to /dev/ttyUSB0.\r\n"
"[baud] - baud rate. 9600, 19200, 38400, 57600, 115200\r\n"
" defaults to 38400.\r\n" "[network] - network interface.\r\n"
" defaults to eth0.\r\n" "");
return 0;
}
/* initialize our interface */
if (argc > 1) {
RS485_Set_Interface(argv[1]);
}
if (argc > 2) {
my_baud = strtol(argv[2], NULL, 0); //把argv[2]按照十进制转换
}
if (argc > 3) {
my_interface = argv[3];
}
sockfd = network_init(my_interface, ETH_P_ALL);
if (sockfd == -1) {
return 1;
} //设置一些MS/TP协议里面的内容参数,这部分要求熟悉MS/TP协议内容,具体可参考教材<智能楼宇BACnet原理与控制>
RS485_Set_Baud_Rate(my_baud);
RS485_Initialize();
MSTP_Port.InputBuffer = &RxBuffer[0];
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
MSTP_Port.OutputBuffer = &TxBuffer[0];
MSTP_Port.OutputBufferSize = sizeof(TxBuffer);
MSTP_Port.This_Station = 127;
MSTP_Port.Nmax_info_frames = 1;
MSTP_Port.Nmax_master = 127;
MSTP_Port.SilenceTimer = Timer_Silence;
MSTP_Port.SilenceTimerReset = Timer_Silence_Reset;
MSTP_Init(mstp_port);
fprintf(stdout, "mstpcap: Using %s for capture at %ld bps.\n",
RS485_Interface(), (long) RS485_Get_Baud_Rate());
atexit(cleanup);
#if defined(_WIN32)
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_PROCESSED_INPUT);
SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlCHandler, TRUE);
#else
signal_init();
#endif
/* run forever */
for (;;) {
RS485_Check_UART_Data(mstp_port);
MSTP_Receive_Frame_FSM(mstp_port);
/* process the data portion of the frame */
if (mstp_port->ReceivedValidFrame) {
mstp_port->ReceivedValidFrame = false;
snap_received_packet(mstp_port, sockfd);
packet_count++;
} else if (mstp_port->ReceivedInvalidFrame) {
mstp_port->ReceivedInvalidFrame = false;
fprintf(stderr, "ReceivedInvalidFrame\n");
snap_received_packet(mstp_port, sockfd);
packet_count++;
}
if (!(packet_count % 100)) {
fprintf(stdout, "\r%hu packets", packet_count);
}
}
return 0;
}
有源反馈运算放大器AD8143
AD8143内部结构如图1所示:
AD8143使用一种叫做有源反馈的结构,这种结构不同于常规的运算放大器,最明显的特征是:存在两对独立的差分输入,而常规运算放大器仅一对差分输入;对于有源运反馈结构,通常一对差分输入被差分输入信号驱动,另一对用作反馈。
这种有源反馈结构相比于常规运放有很多优点:非常高的共模抑制比,宽的共模输入范围,高阻抗的输入对和在典型应用中完全平衡,另外,外部反馈网络如同常规运放一样建立增益响应,这种独立的通道完全独立于信号输入,这减少了反馈和输入电路之间的干扰。
另外一个优点是仅仅通过切换差分输入就可以改变增益极性,高输入阻抗的反向放大器因此可以实现,除了高阻抗,单位增益反向器有单位噪声增益,产生低输出噪声和较高的带宽。
需要注意的是,这种结果的差分信号输入端存在比较的差分电压,而不向常规的运算放大器那样输入端的差分电压基本为0。而AD81143允许的差分输入电压仅为2.5V,所以要特别注意这一点,确保不要超过这个范围,必要时要施加保护。