本文整理汇总了C++中PRINT函数的典型用法代码示例。如果您正苦于以下问题:C++ PRINT函数的具体用法?C++ PRINT怎么用?C++ PRINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PRINT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: motorAxisSetDouble
static int motorAxisSetDouble(AXIS_HDL pAxis, motorAxisParam_t function, double value)
{
int ret_status = MOTOR_AXIS_ERROR;
double deviceValue;
char buff[100];
if (pAxis == NULL)
return MOTOR_AXIS_ERROR;
else
{
epicsMutexLock(pAxis->mutexId);
switch (function)
{
case motorAxisPosition:
{
deviceValue = value*pAxis->stepSize;
sprintf(buff, "%dSH%.*f;%dDH;%dSH%.*f", pAxis->axis+1, pAxis->maxDigits, deviceValue,
pAxis->axis+1, pAxis->axis+1, pAxis->maxDigits, pAxis->homePreset);
ret_status = sendOnly(pAxis->pController, buff);
break;
}
case motorAxisEncoderRatio:
{
PRINT(pAxis->logParam, MOTOR_ERROR, "motorAxisSetDouble: MM4000 does not support setting encoder ratio\n");
break;
}
case motorAxisResolution:
{
PRINT(pAxis->logParam, MOTOR_ERROR, "motorAxisSetDouble: MM4000 does not support setting resolution\n");
break;
}
case motorAxisLowLimit:
{
deviceValue = value*pAxis->stepSize;
sprintf(buff, "%dSL%.*f", pAxis->axis+1, pAxis->maxDigits, deviceValue);
ret_status = sendOnly(pAxis->pController, buff);
break;
}
case motorAxisHighLimit:
{
deviceValue = value*pAxis->stepSize;
sprintf(buff, "%dSR%.*f", pAxis->axis+1, pAxis->maxDigits, deviceValue);
ret_status = sendOnly(pAxis->pController, buff);
break;
}
case motorAxisPGain:
{
PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000 does not support setting proportional gain\n");
break;
}
case motorAxisIGain:
{
PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000 does not support setting integral gain\n");
break;
}
case motorAxisDGain:
{
PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000 does not support setting derivative gain\n");
break;
}
default:
PRINT(pAxis->logParam, MOTOR_ERROR, "motorAxisSetDouble: unknown function %d\n", function);
break;
}
if (ret_status == MOTOR_AXIS_OK )
{
motorParam->setDouble(pAxis->params, function, value);
motorParam->callCallback(pAxis->params);
}
epicsMutexUnlock(pAxis->mutexId);
}
return ret_status;
}
示例2: PRINT
void AbstractFileInterfaceNode::Start(
bigtime_t performance_time)
{
PRINT("AbstractFileInterfaceNode::Start(pt=%lld)\n",performance_time);
BMediaEventLooper::Start(performance_time);
}
示例3: dump_cook_context
static void dump_cook_context(COOKContext *q)
{
//int i=0;
#define PRINT(a, b) av_dlog(q->avctx, " %s = %d\n", a, b);
av_dlog(q->avctx, "COOKextradata\n");
av_dlog(q->avctx, "cookversion=%x\n", q->subpacket[0].cookversion);
if (q->subpacket[0].cookversion > STEREO) {
PRINT("js_subband_start", q->subpacket[0].js_subband_start);
PRINT("js_vlc_bits", q->subpacket[0].js_vlc_bits);
}
av_dlog(q->avctx, "COOKContext\n");
PRINT("nb_channels", q->avctx->channels);
PRINT("bit_rate", q->avctx->bit_rate);
PRINT("sample_rate", q->avctx->sample_rate);
PRINT("samples_per_channel", q->subpacket[0].samples_per_channel);
PRINT("subbands", q->subpacket[0].subbands);
PRINT("js_subband_start", q->subpacket[0].js_subband_start);
PRINT("log2_numvector_size", q->subpacket[0].log2_numvector_size);
PRINT("numvector_size", q->subpacket[0].numvector_size);
PRINT("total_subbands", q->subpacket[0].total_subbands);
}
示例4: PRINT
void FlipTransition::stopFilter() {
PRINT(("FlipTransition::stopFilter()\n"));
}
示例5: DoMacro
static void
DoMacro(
char *line) /* The line of text that contains the macro
* invocation. */
{
char *p, *end;
int quote;
/*
* If there is no macro name, then just skip the whole line.
*/
if ((line[1] == 0) || (isspace(line[1]))) {
return;
}
PRINT(("macro"));
if (*line != '.') {
PRINT(("2"));
}
/*
* Parse the arguments to the macro (including the name), in order.
*/
p = line+1;
while (1) {
PRINTC(' ');
if (*p == '"') {
/*
* The argument is delimited by quotes.
*/
for (end = p+1; *end != '"'; end++) {
if (*end == 0) {
fprintf(stderr,
"Unclosed quote in macro call on line %d.\n",
lineNumber);
status = 1;
break;
}
}
QuoteText(p+1, (end-(p+1)));
} else {
quote = 0;
for (end = p+1; (*end != 0) && (quote || !isspace(*end)); end++) {
if (*end == '\'') {
quote = !quote;
}
}
QuoteText(p, end-p);
}
if (*end == 0) {
break;
}
p = end+1;
while (isspace(*p)) {
/*
* Skip empty space before next argument.
*/
p++;
}
if (*p == 0) {
break;
}
}
PRINTC('\n');
}
示例6: SER_AB8500_CORE_Init
void SER_AB8500_CORE_Init()
{
t_gic_error gic_error;
t_uint32 old_datum,i;
t_ser_ab8500_core_error ab8500_error;
t_uint8 data_out[24], data_in[24];
t_gic_config_cntrl gic_config;
(gic_config.prio_level) = GIC_PR_LEVEL_0;
(gic_config.it_sec) = GIC_IT_NON_SEC;
(gic_config.it_config) = GIC_IT_EDGE_SENSITIVE;
(gic_config.cpu_num) = GIC_CPU_CORE_0;
gic_error = GIC_DisableItLine(GIC_IRQ_N_LINE);
if (gic_error != GIC_OK)
{
PRINT("GIC Disabling AB8500 Line error - %d\n", gic_error);
}
gic_error = GIC_DisableItLine(GIC_PRCMU_NON_SECURE_LINE);
if (gic_error != GIC_OK)
{
PRINT("GIC Disabling PRCMU Line error - %d\n", gic_error);
}
gic_error = GIC_ConfigureIrqLine(GIC_IRQ_N_LINE, (t_gic_func_ptr) SER_AB8500_CORE_InterruptHandler, &gic_config);
if (gic_error != GIC_OK)
{
PRINT("GIC Interrupt Handler Binding error - %d\n", gic_error);
}
gic_error = GIC_ChangeDatum(GIC_PRCMU_NON_SECURE_LINE, (t_gic_func_ptr) SER_AB8500_CORE_PRCMUInterruptHandler, (t_gic_func_ptr *)&old_datum);
if (gic_error != GIC_OK)
{
PRINT("GIC Interrupt Handler Binding error - %d\n", gic_error);
}
for(i=0;i<0x17;i++)
data_out[i]=0xFF;
/* Disable all masks */
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_MASK_1_REGISTER, 22, data_out))
{
PRINT("SER_AB8500_CORE_Write(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_MASK_1_REGISTER, 10, data_out) FAILED!!!.");
return;
}
/* Read to clear all latches */
/*coverity[uninit_use_in_call]*/
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Read(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_LATCH_1_REGISTER, 22, data_in, data_out))
{
PRINT("SER_AB8500_CORE_Read(AB8500_CORE_INTERRUPT_BLOCK, AB8500_CORE_IT_LATCH_1_REGISTER, 24, data_in, data_out) FAILED!!!.");
return;
}
#if 0
/* For USB */
/* Enable all reqd USB masks */
data_out[0]=0x00;
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x0E, 0x69, 0x1, data_out))
{
PRINT("SER_AB8500_CORE_Write(0x0E, 0x40, 0x17, data_out) FAILED!!!.");
return;
}
data_out[0]=0x00;
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x0E, 0x6F, 0x1, data_out))
{
PRINT("SER_AB8500_CORE_Write(0x0E, 0x40, 0x17, data_out) FAILED!!!.");
return;
}
data_out[0]=0x00;
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x0E, 0x72, 0x1, data_out))
{
PRINT("SER_AB8500_CORE_Write(0x0E, 0x40, 0x17, data_out) FAILED!!!.");
return;
}
/* Watchdog settings: Enable*/
/* Watchdog settings: Enable */
data_out = 0x00;
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x03, 0x2F, 0x01, &data_out))
{
PRINT("SER_AB8500_CORE_Write(0x02, 0x01, 0x01, data_out) FAILED for data_out 0x01!!!");
return;
}
/* Watchdog settings: Kick */
data_out = 0x04;
if(SER_AB8500_CORE_OK != SER_AB8500_CORE_Write(0x02, 0x2F, 0x01, &data_out))
{
PRINT("SER_AB8500_CORE_Write(0x02, 0x01, 0x01, data_out) FAILED for data_out 0x03!!!.");
return;
}
/* Watchdog settings: Disable */
//.........这里部分代码省略.........
示例7: handle_device
void handle_device(AMDeviceRef device) {
if (found_device) return; // handle one device only
CFStringRef found_device_id = AMDeviceCopyDeviceIdentifier(device);
PRINT ("found device id\n");
if (device_id != NULL) {
if(strcmp(device_id, CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding())) == 0) {
found_device = true;
} else {
return;
}
} else {
if (operation == OP_LIST_DEVICES) {
printf ("%s\n", CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding()));
CFRetain(device); // don't know if this is necessary?
return;
}
found_device = true;
}
CFRetain(device); // don't know if this is necessary?
PRINT("[ 0%%] Found device (%s), beginning install\n", CFStringGetCStringPtr(found_device_id, CFStringGetSystemEncoding()));
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
CFStringRef path = CFStringCreateWithCString(NULL, app_path, kCFStringEncodingASCII);
CFURLRef relative_url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, false);
CFURLRef url = CFURLCopyAbsoluteURL(relative_url);
CFRelease(relative_url);
int afcFd;
int startServiceAFCRetval = AMDeviceStartService(device, CFSTR("com.apple.afc"), (service_conn_t *) &afcFd, NULL);
printf("trying to start com.apple.afc : %d\n", startServiceAFCRetval);
if( startServiceAFCRetval )
{
sleep(1);
//printf("trying to start com.apple.afc\n");
startServiceAFCRetval = AMDeviceStartService(device, CFSTR("com.apple.afc"), (service_conn_t *) &afcFd, NULL);
}
printf("trying to start com.apple.afc : %d\n", startServiceAFCRetval);
assert(startServiceAFCRetval == 0);
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
if (operation == OP_INSTALL) {
assert(AMDeviceTransferApplication(afcFd, path, NULL, transfer_callback, NULL) == 0);
close(afcFd);
}
CFStringRef keys[] = { CFSTR("PackageType") };
CFStringRef values[] = { CFSTR("Developer") };
CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
AMDeviceConnect(device);
assert(AMDeviceIsPaired(device));
assert(AMDeviceValidatePairing(device) == 0);
assert(AMDeviceStartSession(device) == 0);
int installFd;
assert(AMDeviceStartService(device, CFSTR("com.apple.mobile.installation_proxy"), (service_conn_t *) &installFd, NULL) == 0);
//assert(AMDeviceStopSession(device) == 0);
//assert(AMDeviceDisconnect(device) == 0);
if (operation == OP_INSTALL) {
mach_error_t result = AMDeviceSecureInstallApplication(0, device, url, options, &operation_callback, 0);
//mach_error_t result = AMDeviceInstallApplication(installFd, path, options, operation_callback, NULL);
if (result != 0)
{
PRINT("AMDeviceInstallApplication failed: %d\n", result);
exit(EXIT_FAILURE);
}
}
else if (operation == OP_UNINSTALL) {
mach_error_t result = AMDeviceUninstallApplication (installFd, path, NULL, operation_callback, NULL);
if (result != 0)
{
PRINT("AMDeviceUninstallApplication failed: %d\n", result);
exit(EXIT_FAILURE);
}
}
assert(AMDeviceStopSession(device) == 0);
assert(AMDeviceDisconnect(device) == 0);
close(installFd);
CFRelease(path);
CFRelease(options);
if (operation == OP_INSTALL)
PRINT("[100%%] Installed package %s\n", app_path);
//.........这里部分代码省略.........
示例8: timeout_callback
void timeout_callback(CFRunLoopTimerRef timer, void *info) {
if (!found_device) {
PRINT("Timed out waiting for device.\n");
exit(EXIT_FAILURE);
}
}
示例9: load_rom
void load_rom(struct mmu_t *mmu, const char *path) {
FILE *romfile = fopen(path, "rb");
if(romfile == NULL) {
ERROR("File error: does not exist?\n");
exit(1);
}
// Get file size
fseek(romfile, 0L, SEEK_END);
long size = ftell(romfile);
fseek(romfile, 0L, SEEK_SET);
INFO("File size is %ld\n", size);
mmu->rom = (byte *)malloc(size * sizeof(byte));
if(mmu->rom == NULL) {
ERROR("Memory error: unable to allocate enough ram\n");
exit(2);
}
long result = fread(mmu->rom, sizeof(byte), size, romfile);
/* INFO("Result is %ld\n", result); */
if(result != size) {
ERROR("Reading error\n");
exit(3);
}
fclose(romfile);
// Allocate ERAM based on rom values at specific addresses and size of rom
INFO("Internal RAM: ");
switch(mmu->rom[0x0149]) {
case 0: // No RAM
// Optionally allocate 8 KB external ram
PRINT("No internal RAM\n");
break;
case 1: // 2 KB = 1 Bank
PRINT("1 Bank (2 KB)\n");
mmu->eram = (byte *)malloc(2048 * sizeof(byte));
break;
case 2: // 8 KB = 1 Bank
PRINT("1 Bank (8 KB)\n");
mmu->eram = (byte *)malloc(8192 * sizeof(byte));
break;
case 3: // 32 KB = 4 Banks
PRINT("4 Banks (32 KB)\n");
mmu->eram = (byte *)malloc(32768 * sizeof(byte));
break;
case 4: // 128 KB = 16 Banks
PRINT("16 Banks (128 KB)\n");
mmu->eram = (byte *)malloc(128 * 1024 * sizeof(byte));
break;
}
// Set cartridge types
mmu->rom_type = mmu->rom[0x0147];
#ifdef DEBUG
INFO("Rom type: ");
switch(mmu->rom_type) {
case ROM_ONLY: // ROM Only
PRINT("ROM only\n");
break;
case MBC1: // ROM + MBC1
PRINT("MBC1\n");
break;
case MBC1_RAM: // ROM + MBC1 + RAM
PRINT("MBC1 + RAM\n");
break;
case MBC1_RAM_BATT: // ROM + MBC1 + RAM + BATT
PRINT("MBC1 + RAM + BATT\n");
break;
case MBC2: // ROM + MBC2
PRINT("MBC2\n");
break;
case MBC2_BATT: // ROM + MBC2 + BATT
PRINT("MBC2 + BATT\n");
break;
case RAM: // ROM + RAM
PRINT("RAM\n");
break;
case RAM_BATT: // ROM + RAM + BATT
PRINT("RAM + BATT\n");
break;
case MMMO1: // ROM + MMMO1
PRINT("MMMO1\n");
break;
case MMMO1_SRAM: // ROM + MMMO1 + SRAM
PRINT("MMMO1 + SRAM\n");
break;
case 0xD: // ROM + MMMO1 + SRAM + BATT
PRINT("MMMO1 + SRAM + BATT\n");
break;
case 0xF: // ROM + MBC3 + TIMER + BATT
PRINT("MBC3 + TIMER + BATT\n");
break;
case 0x10: // ROM + MBC3 + TIMER + RAM + BATT
PRINT("MBC3 + TIMER + RAM + BATT\n");
break;
case 0x11: // ROM + MBC3
PRINT("MBC3\n");
//.........这里部分代码省略.........
示例10: invert_cpu
/*
* Inverts a square matrix (stored as a 1D float array)
*
* actualsize - the dimension of the matrix
*
* written by Mike Dinolfo 12/98
* version 1.0
*/
void invert_cpu(float* data, int actualsize, float* log_determinant) {
int maxsize = actualsize;
int n = actualsize;
*log_determinant = 0.0;
/*DEBUG("\n\nR matrix before inversion:\n");
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
DEBUG("%.4f ",data[i*n+j]);
}
DEBUG("\n");
}*/
if (actualsize == 1) { // special case, dimensionality == 1
*log_determinant = logf(data[0]);
data[0] = 1.0 / data[0];
} else if(actualsize >= 2) { // dimensionality >= 2
for (int i=1; i < actualsize; i++) data[i] /= data[0]; // normalize row 0
for (int i=1; i < actualsize; i++) {
for (int j=i; j < actualsize; j++) { // do a column of L
float sum = 0.0;
for (int k = 0; k < i; k++)
sum += data[j*maxsize+k] * data[k*maxsize+i];
data[j*maxsize+i] -= sum;
}
if (i == actualsize-1) continue;
for (int j=i+1; j < actualsize; j++) { // do a row of U
float sum = 0.0;
for (int k = 0; k < i; k++)
sum += data[i*maxsize+k]*data[k*maxsize+j];
data[i*maxsize+j] =
(data[i*maxsize+j]-sum) / data[i*maxsize+i];
}
}
for(int i=0; i<actualsize; i++) {
*log_determinant += log10(fabs(data[i*n+i]));
//printf("log_determinant: %e\n",*log_determinant);
}
//printf("\n\n");
for ( int i = 0; i < actualsize; i++ ) // invert L
for ( int j = i; j < actualsize; j++ ) {
float x = 1.0;
if ( i != j ) {
x = 0.0;
for ( int k = i; k < j; k++ )
x -= data[j*maxsize+k]*data[k*maxsize+i];
}
data[j*maxsize+i] = x / data[j*maxsize+j];
}
for ( int i = 0; i < actualsize; i++ ) // invert U
for ( int j = i; j < actualsize; j++ ) {
if ( i == j ) continue;
float sum = 0.0;
for ( int k = i; k < j; k++ )
sum += data[k*maxsize+j]*( (i==k) ? 1.0 : data[i*maxsize+k] );
data[i*maxsize+j] = -sum;
}
for ( int i = 0; i < actualsize; i++ ) // final inversion
for ( int j = 0; j < actualsize; j++ ) {
float sum = 0.0;
for ( int k = ((i>j)?i:j); k < actualsize; k++ )
sum += ((j==k)?1.0:data[j*maxsize+k])*data[k*maxsize+i];
data[j*maxsize+i] = sum;
}
/*DEBUG("\n\nR matrix after inversion:\n");
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
DEBUG("%.2f ",data[i*n+j]);
}
DEBUG("\n");
}*/
} else {
PRINT("Error: Invalid dimensionality for invert(...)\n");
}
}
示例11: BuildDocumentString
VOID APIENTRY BuildDocumentString()
{
register LPSTR p;
register INT len;
INT lenDocs;
CHAR szT[10];
INT i;
HKEY hk;
ENTER("BuildDocumentString");
len = 32;
/* Get all of the "Documents=" stuff. */
szDocuments = (LPSTR)LocalAlloc(LPTR, len);
if (!szDocuments)
return;
while ((lenDocs = GetProfileString(szWindows, "Documents", szNULL, szDocuments, len-1)) == len-1)
{
len += 32;
szDocuments = (LPSTR)LocalReAlloc((HANDLE)szDocuments, len, LMEM_MOVEABLE);
if (!szDocuments) {
LEAVE("BuildDocumentString");
return;
}
}
lstrcat(szDocuments, szBlank);
lenDocs++;
p = (LPSTR)(szDocuments + lenDocs);
/* Read all of the [Extensions] keywords into 'szDocuments'. */
while ((INT)GetProfileString(szExtensions, NULL, szNULL, p, len-lenDocs) > (len-lenDocs-3))
{
len += 32;
szDocuments = (LPSTR)LocalReAlloc((HANDLE)szDocuments, len, LMEM_MOVEABLE);
if (!szDocuments) {
LEAVE("BuildDocumentString");
return;
}
p = (LPSTR)(szDocuments + lenDocs);
}
/* Step through each of the keywords in 'szDocuments' changing NULLS into
* spaces until a double-NULL is found.
*/
p = szDocuments;
while (*p)
{
/* Find the next NULL. */
while (*p)
p++;
/* Change it into a space. */
*p = ' ';
p++;
}
if (RegOpenKey(HKEY_CLASSES_ROOT,szNULL,&hk) == ERROR_SUCCESS)
{
/* now enumerate the classes in the registration database and get all
* those that are of the form *.ext
*/
for (i = 0; RegEnumKey(hk,(DWORD)i,szT,sizeof(szT))
== ERROR_SUCCESS; i++)
{
if (szT[0] != '.' ||
(szT[1] && szT[2] && szT[3] && szT[4]))
{
/* either the class does not start with . or it has a greater
* than 3 byte extension... skip it.
*/
continue;
}
if (FindExtensionInList(szT+2,szDocuments))
{
// don't add it if it's already there!
continue;
}
len += 4;
szDocuments = (PSTR)LocalReAlloc((HANDLE)szDocuments, len,
LMEM_MOVEABLE);
if (!szDocuments)
break;
lstrcat(szDocuments, szT+1);
lstrcat(szDocuments, szBlank);
}
RegCloseKey(hk);
}
PRINT(BF_PARMTRACE, "OUT: szDocuments=%s", szDocuments);
LEAVE("BuildDocumentString - ok");
return;
//.........这里部分代码省略.........
示例12: url
void
UrlWrapper::ArgvReceived(int32 argc, char** argv)
{
if (argc <= 1)
return;
const char* failc = " || read -p 'Press any key'";
const char* pausec = " ; read -p 'Press any key'";
char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL};
status_t err;
BUrl url(argv[1]);
BString full = BUrl(url).SetProtocol(BString()).UrlString();
BString proto = url.Protocol();
BString host = url.Host();
BString port = BString() << url.Port();
BString user = url.UserInfo();
BString pass = url.Password();
BString path = url.Path();
if (!url.IsValid()) {
fprintf(stderr, "malformed url: '%s'\n", url.UrlString().String());
return;
}
// XXX: debug
PRINT(("PROTO='%s'\n", proto.String()));
PRINT(("HOST='%s'\n", host.String()));
PRINT(("PORT='%s'\n", port.String()));
PRINT(("USER='%s'\n", user.String()));
PRINT(("PASS='%s'\n", pass.String()));
PRINT(("PATH='%s'\n", path.String()));
if (proto == "about") {
app_info info;
BString sig;
// BUrl could get an accessor for the full - proto part...
sig = host << "/" << path;
BMessage msg(B_ABOUT_REQUESTED);
if (be_roster->GetAppInfo(sig.String(), &info) == B_OK) {
BMessenger msgr(sig.String());
msgr.SendMessage(&msg);
return;
}
if (be_roster->Launch(sig.String(), &msg) == B_OK)
return;
be_roster->Launch("application/x-vnd.Haiku-About");
return;
}
if (proto == "telnet") {
BString cmd("telnet ");
if (url.HasUserInfo())
cmd << "-l " << user << " ";
cmd << host;
if (url.HasPort())
cmd << " " << port;
PRINT(("CMD='%s'\n", cmd.String()));
cmd << failc;
args[2] = (char*)cmd.String();
be_roster->Launch(kTerminalSig, 3, args);
return;
}
// see draft:
// http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/
if (proto == "ssh") {
BString cmd("ssh ");
if (url.HasUserInfo())
cmd << "-l " << user << " ";
if (url.HasPort())
cmd << "-oPort=" << port << " ";
cmd << host;
PRINT(("CMD='%s'\n", cmd.String()));
cmd << failc;
args[2] = (char*)cmd.String();
be_roster->Launch(kTerminalSig, 3, args);
// TODO: handle errors
return;
}
if (proto == "ftp") {
BString cmd("ftp ");
cmd << proto << "://";
/*
if (user.Length())
cmd << "-l " << user << " ";
cmd << host;
*/
cmd << full;
PRINT(("CMD='%s'\n", cmd.String()));
cmd << failc;
args[2] = (char*)cmd.String();
be_roster->Launch(kTerminalSig, 3, args);
// TODO: handle errors
return;
}
//.........这里部分代码省略.........
示例13: MM4000Poller
static void MM4000Poller(MM4000Controller *pController)
{
/* This is the task that polls the MM4000 */
double timeout;
AXIS_HDL pAxis;
int status;
int itera, j;
int axisDone;
int offset;
int anyMoving;
int comStatus;
int forcedFastPolls=0;
char *p, *tokSave;
char statusAllString[BUFFER_SIZE];
char positionAllString[BUFFER_SIZE];
char buff[BUFFER_SIZE];
timeout = pController->idlePollPeriod;
epicsEventSignal(pController->pollEventId); /* Force on poll at startup */
while (1)
{
if (timeout != 0.)
status = epicsEventWaitWithTimeout(pController->pollEventId, timeout);
else
status = epicsEventWait(pController->pollEventId);
if (status == epicsEventWaitOK)
{
/* We got an event, rather than a timeout. This is because other software
* knows that an axis should have changed state (started moving, etc.).
* Force a minimum number of fast polls, because the controller status
* might not have changed the first few polls
*/
forcedFastPolls = 10;
}
anyMoving = 0;
/* Lock all the controller's axis. */
for (itera = 0; itera < pController->numAxes; itera++)
{
pAxis = &pController->pAxis[itera];
if (!pAxis->mutexId)
break;
epicsMutexLock(pAxis->mutexId);
}
comStatus = sendAndReceive(pController, "MS;", statusAllString, sizeof(statusAllString));
if (comStatus == 0)
comStatus = sendAndReceive(pController, "TP;", positionAllString, sizeof(positionAllString));
for (itera=0; itera < pController->numAxes; itera++)
{
pAxis = &pController->pAxis[itera];
if (!pAxis->mutexId)
break;
if (comStatus != 0)
{
PRINT(pAxis->logParam, MOTOR_ERROR, "MM4000Poller: error reading status=%d\n", comStatus);
motorParam->setInteger(pAxis->params, motorAxisCommError, 1);
}
else
{
PARAMS params = pAxis->params;
int intval, axisStatus;
motorParam->setInteger(params, motorAxisCommError, 0);
/*
* Parse the status string
* Status string format: 1MSx,2MSy,3MSz,... where x, y and z are the status
* bytes for the motors
*/
offset = pAxis->axis*5 + 3; /* Offset in status string */
axisStatus = pAxis->axisStatus = statusAllString[offset];
if (axisStatus & MM4000_MOVING)
{
axisDone = 0;
anyMoving = 1;
}
else
axisDone = 1;
motorParam->setInteger(params, motorAxisDone, axisDone);
motorParam->setInteger(params, motorAxisHomeSignal, (axisStatus & MM4000_HOME));
motorParam->setInteger(params, motorAxisHighHardLimit, (axisStatus & MM4000_HIGH_LIMIT));
motorParam->setInteger(params, motorAxisLowHardLimit, (axisStatus & MM4000_LOW_LIMIT));
motorParam->setInteger(params, motorAxisDirection, (axisStatus & MM4000_DIRECTION));
motorParam->setInteger(params, motorAxisPowerOn, !(axisStatus & MM4000_POWER_OFF));
/*
* Parse motor position
* Position string format: 1TP5.012,2TP1.123,3TP-100.567,...
* Skip to substring for this motor, convert to double
*/
strcpy(buff, positionAllString);
tokSave = NULL;
p = epicsStrtok_r(buff, ",", &tokSave);
for (j=0; j < pAxis->axis; j++)
//.........这里部分代码省略.........
示例14: return
PUBLIC t_ser_ab8500_core_error SER_AB8500_CORE_Read
(
IN t_uint8 block_add,
IN t_uint8 register_offset,
IN t_uint8 count,
IN t_uint8 *p_data_in,
OUT t_uint8 *p_data_out
)
{
t_ser_ab8500_core_error error_ab8500 = SER_AB8500_CORE_OK;
#ifndef __PRCM_HWI2C
t_ssp_error error_ssp = SSP_OK;
t_ssp_device_id ssp_device_id = SSP_DEVICE_ID_0;
t_uint32 rx_element,index = 0x00;
t_uint32 data_packet=0x00;
if(SSP_OK != SSP_Enable(ssp_device_id, SSP_DISABLE_RX_TX))
{
return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED);
}
/* flush receive fifo */
ser_ab8500_core_FlushRecieveFifo();
if(count <= SER_AB8500_CORE_SSPFIFO)
{
/* Perform Dummy read for first 0x00 data read with SSP */
error_ab8500 = ser_ab8500_ReadSingleFifoTransaction(0x01, 0x00, 1, p_data_in, p_data_out);
if(SER_AB8500_CORE_OK != error_ab8500)
{
return(error_ab8500);
}
/* Now perform proper read */
error_ab8500 = ser_ab8500_ReadSingleFifoTransaction(block_add, register_offset, count, p_data_in, p_data_out);
if(SER_AB8500_CORE_OK != error_ab8500)
{
return(error_ab8500);
}
}
else
{
/* Perform Dummy read for first 0x00 data read with SSP */
error_ab8500 = ser_ab8500_ReadSingleFifoTransaction(0x01, 0x00, 1, p_data_in, p_data_out);
if(SER_AB8500_CORE_OK != error_ab8500)
{
return(error_ab8500);
}
/* Now perform proper read */
while ((index < SER_AB8500_CORE_SSPFIFO) && (SSP_OK == error_ssp))
{
/* Data transmitted is write command and block address */
block_add = (t_uint8)((MASK_BIT5) & block_add);
data_packet = ((block_add << SHIFT_BYTE1) | register_offset);
/* Tx FIFO is filled before enabling SSP */
data_packet = ((data_packet << SHIFT_AB8500_DATA) | *p_data_in);
error_ssp = SSP_SetData(ssp_device_id,data_packet);
p_data_in++;
register_offset++;
index++;
}
count = count - SER_AB8500_CORE_SSPFIFO;
if(SSP_OK != error_ssp)
{
PRINT("SSP0 Error %d", error_ssp);
return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED);
}
/* SSP is enabled */
if(SSP_OK != SSP_Enable(ssp_device_id, SSP_ENABLE_RX_TX))
{
PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED");
return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED);
}
/* Data recieved */
index = 0;
while (index < SER_AB8500_CORE_SSPFIFO)
{
if(SSP_OK != SSP_GetData(ssp_device_id,&rx_element))
{
PRINT("SSP0 Error SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED");
return(SER_AB8500_CORE_TRANSACTION_ON_SPI_FAILED);
}
*p_data_out = (rx_element & MASK_ALL8);
p_data_out++;
index++;
}
while(count)
{
/* Data transmitted is write command and block address */
block_add = (t_uint8)((MASK_BIT5) & block_add);
//.........这里部分代码省略.........
示例15: main
int main(int argc, char *argv[]) {
static struct option global_longopts[]= {
{ "quiet", no_argument, NULL, 'q' },
{ "verbose", no_argument, NULL, 'v' },
{ "timeout", required_argument, NULL, 't' },
{ "id", required_argument, NULL, 'i' },
{ "bundle", required_argument, NULL, 'b' },
{ "debug", no_argument, NULL, 'd' },
{ "args", required_argument, NULL, 'a' },
{ NULL, 0, NULL, 0 },
};
char ch;
while ((ch = getopt_long(argc, argv, "qvtibda:", global_longopts, NULL)) != -1)
{
switch (ch) {
case 'q':
quiet = 1;
break;
case 'v':
verbose = 1;
break;
case 'd':
debug = 1;
break;
case 't':
timeout = atoi(optarg);
break;
case 'b':
app_path = optarg;
break;
case 'a':
args = optarg;
break;
case 'i':
device_id = optarg;
break;
default:
usage(argv[0]);
return 1;
}
}
if (optind >= argc) {
usage(argv [0]);
exit(EXIT_SUCCESS);
}
operation = OP_NONE;
if (strcmp (argv [optind], "install") == 0) {
operation = OP_INSTALL;
} else if (strcmp (argv [optind], "uninstall") == 0) {
operation = OP_UNINSTALL;
} else if (strcmp (argv [optind], "list-devices") == 0) {
operation = OP_LIST_DEVICES;
} else {
usage (argv [0]);
exit(EXIT_SUCCESS);
}
if (operation != OP_LIST_DEVICES && !app_path) {
usage(argv[0]);
exit(EXIT_SUCCESS);
}
if (operation == OP_INSTALL)
assert(access(app_path, F_OK) == 0);
AMDSetLogLevel(1+4+2+8+16+32+64+128); // otherwise syslog gets flooded with crap
if (timeout > 0)
{
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL);
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
PRINT("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout);
}
else
{
PRINT("[....] Waiting for iOS device to be connected\n");
}
struct am_device_notification *notify;
AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, ¬ify);
CFRunLoopRun();
}