本文整理汇总了C++中can_send函数的典型用法代码示例。如果您正苦于以下问题:C++ can_send函数的具体用法?C++ can_send怎么用?C++ can_send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了can_send函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: THD_FUNCTION
static THD_FUNCTION(m3pyro_continuity_thd, arg)
{
(void)arg;
while(true) {
adcsample_t sampbuf[5];
adcStart(&ADCD1, NULL);
msg_t result = adcConvert(&ADCD1, &adc_grp, sampbuf, 1);
adcStop(&ADCD1);
if(result != MSG_OK) {
m3status_set_error(M3PYRO_COMPONENT_CONTINUITY, M3PYRO_ERROR_ADC);
chThdSleepMilliseconds(500);
continue;
}
uint8_t continuities[4];
continuities[0] = adc_to_resistance(sampbuf[0]);
continuities[1] = adc_to_resistance(sampbuf[1]);
continuities[2] = adc_to_resistance(sampbuf[2]);
continuities[3] = adc_to_resistance(sampbuf[3]);
can_send(CAN_MSG_ID_M3PYRO_CONTINUITY, false,
continuities, sizeof(continuities));
uint8_t supply;
supply = adc_to_voltage(sampbuf[4]);
can_send(CAN_MSG_ID_M3PYRO_SUPPLY_STATUS, false,
&supply, 1);
m3status_set_ok(M3PYRO_COMPONENT_CONTINUITY);
chThdSleepMilliseconds(500);
}
}
开发者ID:cuspaceflight,项目名称:m3-avionics,代码行数:33,代码来源:m3pyro_continuity.c
示例2: main
void main()
{
BYTE cpt_RB4;
BYTE cpt_RB5;
Command cmd;
BYTE param;
int run = 1;
init();
cpt_RB4 = 0;
cpt_RB5 = 0;
avancement = 0;
while(run)
{
if (1 == can_receive(&cmd, ¶m))
{
switch (cmd)
{
case Avancer:
avancer(param);
break;
case Reculer:
reculer(param);
break;
case Degree:
degree();
break;
case Reset:
run = 0;
break;
default:
break;
}
}
if(bouton_RB4_pressed())
{
cpt_RB4++;
can_send(BoutonRB4, cpt_RB4);
}
if(bouton_RB5_pressed())
{
cpt_RB5++;
can_send(BoutonRB5, cpt_RB5);
}
}
}
开发者ID:Yalir,项目名称:Archi1A,代码行数:53,代码来源:main.c
示例3: msg_channel
/* msg_channel_flags()
*
* inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
* say NOTICE must not auto reply
* - pointer to source_p
* - pointer to channel
* - flags
* - pointer to text to send
* output - NONE
* side effects - message given channel either chanop or voice
*/
static void
msg_channel(int p_or_n, struct Client *source_p, struct Channel *chptr,
unsigned int flags, const char *text)
{
unsigned int type = 0;
const char *prefix = "";
if (flags & CHFL_VOICE)
{
type = CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE;
prefix = "+";
}
else if (flags & CHFL_HALFOP)
{
type = CHFL_CHANOP | CHFL_HALFOP;
prefix = "%";
}
else if (flags & CHFL_CHANOP)
{
type = CHFL_CHANOP;
prefix = "@";
}
/* Chanops and voiced can flood their own channel with impunity */
int ret = can_send(chptr, source_p, NULL, text, p_or_n == NOTICE);
if (ret < 0)
{
if (ret == CAN_SEND_OPV || !flood_attack_channel(p_or_n, source_p, chptr))
sendto_channel_butone(source_p, source_p, chptr, type, "%s %s%s :%s",
command[p_or_n], prefix, chptr->name, text);
}
else if (p_or_n != NOTICE)
sendto_one_numeric(source_p, &me, ret, chptr->name, text);
}
开发者ID:akiraaisha,项目名称:ircd-hybrid,代码行数:45,代码来源:m_message.c
示例4: command_reculer
void command_reculer(void)
{
char buf[64];
int n, pic;
printf("De combien de pas ? ");
rs232_read_line(buf);
n = atoi(buf);
printf("Numero du pic ? (1 ou 2) ");
rs232_read_line(buf);
pic = atoi(buf);
if(pic == 1)
{
if (avancement - n >= 0 && avancement - n < 256)
{
avancement -= n;
}
else
{
printf("Vous devez donner un nombre de pas permettant de rester entre 0 et 255. L'avancement actuel est déjà de %ld pas." NL, avancement);
}
led_afficher_int(avancement);
}
else if(pic == 2)
{
can_send(Reculer, n);
}
else
{
printf("Le numéro du pic choisi n'est pas valable" NL);
}
}
开发者ID:Yalir,项目名称:Archi1A,代码行数:35,代码来源:commands.c
示例5: m_quit
/*
* m_quit
* parv[0] = sender prefix
* parv[1] = comment
*/
int m_quit(struct Client *cptr,
struct Client *sptr,
int parc,
char *parv[])
#ifdef TIDY_QUIT
{
buf[0] = '\0';
if ((parc > 1) && parv[1])
{
if (strlen(parv[1]) > (MAX_QUIT_LENGTH - 2))
parv[1][MAX_QUIT_LENGTH - 2] = '\0';
/* Don't add quotes to a null message */
if (MyConnect(sptr) && *parv[1])
{
strncpy_irc(buf, "\"", 2);
strncat(buf, strip_colour(parv[1]), MAX_QUIT_LENGTH - 2);
strncat(buf, "\"", 1);
}
else
strncpy_irc(buf, parv[1], BUFSIZE);
}
sptr->flags |= FLAGS_NORMALEX;
#ifdef ANTI_SPAM_EXIT_MESSAGE
/* Your quit message is suppressed if:
*
* You haven't been connected to the server for long enough
*/
if( !IsServer(sptr) && MyConnect(sptr) &&
(sptr->firsttime + ANTI_SPAM_EXIT_MESSAGE_TIME) > CurrentTime)
strcpy(buf, "Client Quit");
else if (MyConnect(sptr) && IsPerson(sptr))
{
/* Or you are in a channel to which you cannot send */
struct SLink *chptr;
for (chptr = sptr->user->channel; chptr; chptr = chptr->next)
{
if (can_send(sptr, chptr->value.chptr) != 0)
{
strcpy(buf, "Client Quit");
break;
}
}
}
#endif
if (IsPerson(sptr))
{
sendto_local_ops_flag(UMODE_CCONN,
"Client exiting: %s (%[email protected]%s) [%s] [%s] [%s]",
sptr->name, sptr->username, sptr->host,
#ifdef WINTRHAWK
buf,
#else
(sptr->flags & FLAGS_NORMALEX) ? "Client Quit" : comment,
#endif /* WINTRHAWK */
sptr->sockhost, sptr->servptr ? sptr->servptr->name : "<null>");
}
return IsServer(sptr) ? 0 : exit_client(cptr, sptr, sptr, buf);
}
开发者ID:BackupTheBerlios,项目名称:phoenixfn-svn,代码行数:65,代码来源:m_quit.c
示例6: main
int main(void)
{
int reg_spi;
reg_spi = open("/root/spi_if",O_RDWR | O_FSYNC); // Open SPI Interface
printf("reg_spi = %d\n", reg_spi);
if (reg_spi > 0){
printf("spi_if open succeeded\n");
} else {
printf ("Open failed.\n");
switch (errno) {
case EACCES: printf ("Permission denied.\n"); break;
case EMFILE: printf ("No file handle available.\n"); break;
case ENOENT: printf ("File or path not found.\n"); break;
default: printf ("Unknown error.\n"); break;
}
printf("Numero de error %d\n",errno);
}
CanMessage can;
can.id=1;
can.dlc=2;
can.data[0]=0x10;
can.data[1]=0xAA;
mcp_init(reg_spi);
can_send(reg_spi, &can);
close(reg_spi);
return 0;
}
开发者ID:lse-mise-12,项目名称:LSE_2012,代码行数:29,代码来源:main.c
示例7: msg_channel
/* msg_channel()
*
* inputs - flag privmsg or notice
* - pointer to command "PRIVMSG" or "NOTICE"
* - pointer to source_p
* - pointer to channel
* output - NONE
* side effects - message given channel
*/
static void
msg_channel(int p_or_n, const char *command, struct Client *source_p,
struct Channel *chptr, const char *text)
{
int result = 0;
/* Chanops and voiced can flood their own channel with impunity */
if ((result = can_send(chptr, source_p, NULL, text)) < 0)
{
if (result == CAN_SEND_OPV ||
!flood_attack_channel(p_or_n, source_p, chptr))
sendto_channel_butone(source_p, source_p, chptr, 0, "%s %s :%s",
command, chptr->name, text);
}
else
{
if (p_or_n != NOTICE)
{
if (result == ERR_NOCTRLSONCHAN)
sendto_one_numeric(source_p, &me, ERR_NOCTRLSONCHAN,
chptr->name, text);
else if (result == ERR_NEEDREGGEDNICK)
sendto_one_numeric(source_p, &me, ERR_NEEDREGGEDNICK,
chptr->name);
else
sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN,
chptr->name);
}
}
}
开发者ID:Indjov,项目名称:ircd-hybrid,代码行数:39,代码来源:m_message.c
示例8: send_queued
/** Attempt to send data queued for a client.
* @param[in] to Client to send data to.
*/
void send_queued(struct Client *to)
{
assert(0 != to);
assert(0 != cli_local(to));
if (IsBlocked(to) || !can_send(to))
return; /* Don't bother */
while (MsgQLength(&(cli_sendQ(to))) > 0) {
unsigned int len;
if ((len = deliver_it(to, &(cli_sendQ(to))))) {
msgq_delete(&(cli_sendQ(to)), len);
cli_lastsq(to) = MsgQLength(&(cli_sendQ(to))) / 1024;
if (IsBlocked(to)) {
update_write(to);
return;
}
}
else {
if (IsDead(to)) {
char tmp[512];
sprintf(tmp,"Write error: %s", ((cli_sslerror(to)) ? (cli_sslerror(to)) :
((strerror(cli_error(to))) ? (strerror(cli_error(to))) : "Unknown error")) );
dead_link(to, tmp);
}
return;
}
}
/* Ok, sendq is now empty... */
client_drop_sendq(cli_connect(to));
update_write(to);
}
开发者ID:evilnet,项目名称:nefarious2,代码行数:37,代码来源:send.c
示例9: bload_check
/* This is the function that we call periodically during the one
second startup time to see if we have a bootloader request on
the CAN Bus. */
uint8_t
bload_check(void) {
struct CanFrame frame;
uint8_t result, channel, send_node;
result = can_poll_int();
if(result & (1<<CAN_RX0IF)) {
/* If the filters and masks are okay this should be
a firware update command addressed to us. */
can_read(0, &frame);
print_frame(frame); /* Debugging Stuff */
if(frame.data[0] == node_id && frame.data[1] == FIX_FIRMWARE &&
frame.data[2] == BL_VERIFY_LSB && frame.data[3] == BL_VERIFY_MSB) {
/* Save the data from the frame that we need later. */
channel = frame.data[4];
send_node = frame.id & 0x0FF;
/* Build success frame */
frame.id = FIX_NODE_SPECIFIC + node_id;
frame.length = 3;
frame.data[0] = send_node;
frame.data[1] = FIX_FIRMWARE;
frame.data[2] = 0x00;
can_send(0, 3, frame);
/* Jump to load firmware */
load_firmware(channel); /* We should never come back from here */
}
}
return 0;
}
开发者ID:birkelbach,项目名称:CFBL_AT328,代码行数:33,代码来源:bootloader.c
示例10: command_degree
void command_degree(void)
{
char buf[64];
int pic;
unsigned int rheo_val;
printf("Numero du pic ? (1 ou 2) ");
rs232_read_line(buf);
pic = atoi(buf);
if(pic == 1)
{
rheo_get_value(&rheo_val);
printf("La valeur du potentiomètre du PIC 1 est %d."NL, rheo_val);
}
else if(pic == 2)
{
can_send(Degree, 0);
}
else
{
printf("Le numéro du PIC choisi n'est pas valable." NL);
}
}
开发者ID:Yalir,项目名称:Archi1A,代码行数:25,代码来源:commands.c
示例11: part_one_client
/* part_one_client()
*
* inputs - pointer to server
* - pointer to source client to remove
* - char pointer of name of channel to remove from
* output - none
* side effects - remove ONE client given the channel name
*/
static void
part_one_client(struct Client *client_p, struct Client *source_p,
const char *name, char *reason)
{
struct Channel *chptr = NULL;
struct Membership *ms = NULL;
if ((chptr = hash_find_channel(name)) == NULL)
{
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
me.name, source_p->name, name);
return;
}
if ((ms = find_channel_link(source_p, chptr)) == NULL)
{
sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
me.name, source_p->name, name);
return;
}
if (MyConnect(source_p) && !IsOper(source_p))
check_spambot_warning(source_p, NULL);
/*
* Remove user from the old channel (if any)
* only allow /part reasons in -m chans
*/
if(msg_has_colors(reason) && (chptr->mode.mode & MODE_NOCOLOR))
reason = strip_color(reason);
if (reason[0] && (!MyConnect(source_p) ||
((can_send(chptr, source_p, ms) &&
(source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
< CurrentTime))))
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :%s", ID(source_p), chptr->chname,
reason);
sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
":%s PART %s :%s", source_p->name, chptr->chname,
reason);
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%[email protected]%s PART %s :%s",
source_p->name, source_p->username,
source_p->host, chptr->chname, reason);
}
else
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s", ID(source_p), chptr->chname);
sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
":%s PART %s", source_p->name, chptr->chname);
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%[email protected]%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(ms);
}
开发者ID:KSoute,项目名称:oftc-hybrid,代码行数:67,代码来源:m_part.c
示例12: raw_sendmsg
static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size)
{
struct sock *sk = sock->sk;
struct raw_sock *ro = raw_sk(sk);
struct sk_buff *skb;
struct net_device *dev;
int ifindex;
int err;
if (msg->msg_name) {
struct sockaddr_can *addr =
(struct sockaddr_can *)msg->msg_name;
if (addr->can_family != AF_CAN)
return -EINVAL;
ifindex = addr->can_ifindex;
} else
ifindex = ro->ifindex;
if (size != sizeof(struct can_frame))
return -EINVAL;
dev = dev_get_by_index(&init_net, ifindex);
if (!dev)
return -ENXIO;
skb = sock_alloc_send_skb(sk, size, msg->msg_flags & MSG_DONTWAIT,
&err);
if (!skb)
goto put_dev;
err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
if (err < 0)
goto free_skb;
err = sock_tx_timestamp(msg, sk, skb_tx(skb));
if (err < 0)
goto free_skb;
skb->dev = dev;
skb->sk = sk;
err = can_send(skb, ro->loopback);
dev_put(dev);
if (err)
goto send_failed;
return size;
free_skb:
kfree_skb(skb);
put_dev:
dev_put(dev);
send_failed:
return err;
}
开发者ID:AppEngine,项目名称:linux-2.6,代码行数:58,代码来源:raw.c
示例13: m_cycle
static int
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *p, *name;
char *s = LOCAL_COPY(parv[1]);
struct Channel *chptr;
struct membership *msptr;
name = rb_strtok_r(s, ",", &p);
/* Finish the flood grace period... */
if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p);
while(name) {
if((chptr = find_channel(name)) == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
return 0;
}
msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL) {
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
return 0;
}
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
check_spambot_warning(source_p, NULL);
if((is_any_op(msptr) || !MyConnect(source_p) ||
((can_send(chptr, source_p, msptr) > 0 &&
(source_p->localClient->firsttime +
ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) {
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :Cycling", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%[email protected]%s PART %s :Cycling",
source_p->name, source_p->username,
source_p->host, chptr->chname);
} else {
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%[email protected]%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(msptr);
chptr = NULL;
msptr = NULL;
name = rb_strtok_r(NULL, ",", &p);
}
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
return 0;
}
开发者ID:Cloudxtreme,项目名称:elemental-ircd,代码行数:58,代码来源:m_cycle.c
示例14: part_one_client
/*
* part_one_client
*
* inputs - pointer to server
* - pointer to source client to remove
* - char pointer of name of channel to remove from
* output - none
* side effects - remove ONE client given the channel name
*/
static void
part_one_client(struct Client *client_p, struct Client *source_p, char *name, char *reason)
{
struct Channel *chptr;
struct membership *msptr;
if((chptr = find_channel(name)) == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), name);
return;
}
msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL)
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), name);
return;
}
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
check_spambot_warning(source_p, NULL);
/*
* Remove user from the old channel (if any)
* only allow /part reasons in -m chans
*/
if(reason[0] && (is_chanop(msptr) || !MyConnect(source_p) ||
((can_send(chptr, source_p, msptr) > 0 &&
(source_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
< CurrentTime))))
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :%s",
use_id(source_p), chptr->chname, reason);
sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
":%s PART %s :%s",
source_p->name, chptr->chname, reason);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%[email protected]%s PART %s :%s",
source_p->name, source_p->username,
source_p->host, chptr->chname, reason);
}
else
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s",
use_id(source_p), chptr->chname);
sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
":%s PART %s",
source_p->name, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%[email protected]%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(msptr);
}
开发者ID:BackupTheBerlios,项目名称:phoenixfn-svn,代码行数:66,代码来源:m_part.c
示例15: main
int main(void)
{
char c;
uint8_t i;
for (i = 0; i < 8; i++)
msg.b[i] = i + 3;
can_init();
DDRB = _BV(LED_PIN);
uart_init(9600);
while (1) {
c = uart_getchar();
if (buffer_append(&buffer, c)) {
buffer_split(&buffer);
if (strncmp(buffer.b + 3, "GLL", 3) == 0) {
msg.l[0] = dmmtoint(buffer.f[0], buffer.f[1]);
msg.l[1] = dmmtoint(buffer.f[2], buffer.f[3]);
can_send(0x201, msg.b, 8);
} else if (strncmp(buffer.b + 3, "RMC", 3) == 0) {
msg.l[0] = dmmtoint(buffer.f[2], buffer.f[3]);
msg.l[1] = dmmtoint(buffer.f[4], buffer.f[5]);
can_send(0x201, msg.b, 8);
} else if (strncmp(buffer.b + 3, "HDT", 3) == 0) {
msg.s[0] = atof(buffer.f[0]) * 100;
can_send(0x202, msg.b, 2);
} else if (strncmp(buffer.b + 3, "ROT", 3) == 0) {
msg.s[0] = atof(buffer.f[0]) * 100;
can_send(0x203, msg.b, 2);
} else if (strncmp(buffer.b + 3, "VTG", 3) == 0) {
msg.us[0] = atof(buffer.f[0]) * 100;
msg.us[1] = atof(buffer.f[4]) * 100;
if (*buffer.f[5] == 'M')
msg.us[2] = 1000;
else
msg.us[2] = 1852;
can_send(0x204, msg.b, 6);
} else if (strncmp(buffer.b + 3, "DBT", 3) == 0) {
msg.s[0] = atof(buffer.f[2]) * 100;
can_send(0x205, msg.b, 2);
} else if (strncmp(buffer.b + 3, "VBW", 3) == 0) {
msg.s[0] = atof(buffer.f[0]) * 100;
msg.s[1] = atof(buffer.f[1]) * 100;
can_send(0x206, msg.b, 4);
} else if (strncmp(buffer.b + 3, "MWV", 3) == 0) {
msg.us[0] = atof(buffer.f[0]) * 100;
msg.us[1] = atof(buffer.f[2]) * 100;
if (*buffer.f[3] == 'M')
msg.us[2] = 1000;
else
msg.us[2] = 1852;
can_send(0x208, msg.b, 6);
}
}
}
}
开发者ID:aleksipihkanen,项目名称:avrcanbridge,代码行数:54,代码来源:main.c
示例16: raw_sendmsg
static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size)
{
struct sock *sk = sock->sk;
struct raw_opt *ro = raw_sk(sk);
struct sk_buff *skb;
struct net_device *dev;
int ifindex;
int err;
DBG("socket %p, sk %p\n", sock, sk);
if (msg->msg_name) {
struct sockaddr_can *addr =
(struct sockaddr_can *)msg->msg_name;
if (addr->can_family != AF_CAN)
return -EINVAL;
ifindex = addr->can_ifindex;
} else
ifindex = ro->ifindex;
dev = dev_get_by_index(ifindex);
if (!dev) {
DBG("device %d not found\n", ifindex);
return -ENXIO;
}
skb = alloc_skb(size, GFP_KERNEL);
if (!skb) {
dev_put(dev);
return -ENOMEM;
}
err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
if (err < 0) {
kfree_skb(skb);
dev_put(dev);
return err;
}
skb->dev = dev;
skb->sk = sk;
DBG("sending skbuff to interface %d\n", ifindex);
DBG_SKB(skb);
err = can_send(skb, ro->loopback);
dev_put(dev);
if (err)
return err;
return size;
}
开发者ID:BackupTheBerlios,项目名称:socketcan-svn,代码行数:56,代码来源:raw.c
示例17: can_send
void CFsAdapter::lookupForFsuipcChanges() {
for(std::list<CAbstractOffsetFamily*>::iterator it =
m_lstFamilies.begin(); it != m_lstFamilies.end(); it++) {
if((*it)->dataHasChanged()) {
(*it)->update();
can_event_msg_t msg = (*it)->transformToCanMessage();
can_send(msg);
}
}
}
开发者ID:pipi,项目名称:cockpitsim,代码行数:11,代码来源:CFsAdapter.cpp
示例18: altitude_send_changes
int altitude_send_changes(i2c_can_trans_t* trans, long* nextAlt) {
can_event_msg_t msg;
if(altitude_changes_lookup(trans, nextAlt) == 0) {
memset(&msg, 0, sizeof(msg));
msg.id = trans->canId;
*((long *)msg.data)=*nextAlt<<16;
msg.length = 4;
return can_send(msg);
}
return 0;
}
开发者ID:pipi,项目名称:cockpitsim,代码行数:13,代码来源:main.c
示例19: send_buffer
/** Try to send a buffer to a client, queueing it if needed.
* @param[in,out] to Client to send message to.
* @param[in] buf Message to send.
* @param[in] prio If non-zero, send as high priority.
*/
void send_buffer(struct Client* to, struct MsgBuf* buf, int prio)
{
assert(0 != to);
assert(0 != buf);
if (cli_from(to))
to = cli_from(to);
if (!can_send(to))
/*
* This socket has already been marked as dead
*/
return;
if (MsgQLength(&(cli_sendQ(to))) > get_sendq(to)) {
if (IsServer(to))
sendto_opmask(0, SNO_OLDSNO, "Max SendQ limit exceeded for %C: %zu > %zu",
to, MsgQLength(&(cli_sendQ(to))), get_sendq(to));
dead_link(to, "Max sendQ exceeded");
return;
}
Debug((DEBUG_SEND, "Sending [%p] to %s", buf, cli_name(to)));
#if defined(USE_SSL)
if (cli_socket(to).s_ssl)
prio = 0;
#endif
msgq_add(&(cli_sendQ(to)), buf, prio);
client_add_sendq(cli_connect(to), &send_queues);
update_write(to);
/*
* Update statistics. The following is slightly incorrect
* because it counts messages even if queued, but bytes
* only really sent. Queued bytes get updated in SendQueued.
*/
++(cli_sendM(to));
++(cli_sendM(&me));
/*
* This little bit is to stop the sendQ from growing too large when
* there is no need for it to. Thus we call send_queued() every time
* 2k has been added to the queue since the last non-fatal write.
* Also stops us from deliberately building a large sendQ and then
* trying to flood that link with data (possible during the net
* relinking done by servers with a large load).
*/
if (MsgQLength(&(cli_sendQ(to))) / 1024 > cli_lastsq(to))
send_queued(to);
}
开发者ID:mojadita,项目名称:ircd,代码行数:56,代码来源:send.c
示例20: msg_channel
/* msg_channel_flags()
*
* inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
* say NOTICE must not auto reply
* - pointer to command, "PRIVMSG" or "NOTICE"
* - pointer to source_p
* - pointer to channel
* - flags
* - pointer to text to send
* output - NONE
* side effects - message given channel either chanop or voice
*/
static void
msg_channel(int p_or_n, const char *command, struct Client *source_p,
struct Channel *chptr, unsigned int flags, const char *text)
{
int result = 0;
unsigned int type = 0;
const char *prefix = "";
if (flags & CHFL_VOICE)
{
type = CHFL_CHANOP | CHFL_HALFOP | CHFL_VOICE;
prefix = "+";
}
else if (flags & CHFL_HALFOP)
{
type = CHFL_CHANOP | CHFL_HALFOP;
prefix = "%";
}
else if (flags & CHFL_CHANOP)
{
type = CHFL_CHANOP;
prefix = "@";
}
/* Chanops and voiced can flood their own channel with impunity */
if ((result = can_send(chptr, source_p, NULL, text)) < 0)
{
if (result == CAN_SEND_OPV ||
!flood_attack_channel(p_or_n, source_p, chptr))
sendto_channel_butone(source_p, source_p, chptr, type, "%s %s%s :%s",
command, prefix, chptr->name, text);
}
else
{
if (p_or_n != NOTICE)
{
if (result == ERR_NOCTRLSONCHAN)
sendto_one_numeric(source_p, &me, ERR_NOCTRLSONCHAN,
chptr->name, text);
else if (result == ERR_NOCTCP)
sendto_one_numeric(source_p, &me, ERR_NOCTCP,
chptr->name, text);
else if (result == ERR_NEEDREGGEDNICK)
sendto_one_numeric(source_p, &me, ERR_NEEDREGGEDNICK,
chptr->name);
else
sendto_one_numeric(source_p, &me, ERR_CANNOTSENDTOCHAN,
chptr->name);
}
}
}
开发者ID:nask0,项目名称:ircd-hybrid,代码行数:63,代码来源:m_message.c
注:本文中的can_send函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论