/*
* tst-bcm-single.c
*
- * Copyright (c) 2002-2005 Volkswagen Group Electronic Research
+ * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, the following disclaimer and
- * the referenced file 'COPYING'.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Alternatively, provided that this notice is retained in full, this
* software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2 as distributed in the 'COPYING'
- * file from the main directory of the linux kernel source.
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
*
* The provided data structures and external interfaces from this code
* are not restricted to be used by modules with a GPL compatible license.
int main(int argc, char **argv)
{
- int s;
- struct sockaddr_can addr;
- struct ifreq ifr;
+ int s;
+ struct sockaddr_can addr;
+ struct ifreq ifr;
- struct {
- struct bcm_msg_head msg_head;
- struct can_frame frame[4];
- } msg;
+ struct {
+ struct bcm_msg_head msg_head;
+ struct can_frame frame;
+ } msg;
- if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
- perror("socket");
- return 1;
- }
+ if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
+ perror("socket");
+ return 1;
+ }
- addr.can_family = PF_CAN;
- strcpy(ifr.ifr_name, "vcan2");
- ioctl(s, SIOCGIFINDEX, &ifr);
- addr.can_ifindex = ifr.ifr_ifindex;
+ addr.can_family = PF_CAN;
+ strcpy(ifr.ifr_name, "vcan2");
+ ioctl(s, SIOCGIFINDEX, &ifr);
+ addr.can_ifindex = ifr.ifr_ifindex;
- if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- perror("connect");
- return 1;
- }
+ if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ perror("connect");
+ return 1;
+ }
- msg.msg_head.opcode = TX_SEND;
- msg.msg_head.can_id = 0x760;
- msg.msg_head.flags = 0;
- msg.msg_head.nframes = 1;
- msg.msg_head.count = 0;
- msg.msg_head.ival1.tv_sec = 0;
- msg.msg_head.ival1.tv_usec = 0;
- msg.msg_head.ival2.tv_sec = 0;
- msg.msg_head.ival2.tv_usec = 0;
- msg.frame[0].can_id = 0x760;
- msg.frame[0].can_dlc = 6;
- msg.frame[0].data[0] = 0xA1;
- msg.frame[0].data[1] = 0x0F;
- msg.frame[0].data[2] = 0x10;
- msg.frame[0].data[3] = 0x00;
- msg.frame[0].data[4] = 0x00;
- msg.frame[0].data[5] = 0x00;
+ msg.msg_head.opcode = TX_SEND;
+ msg.msg_head.can_id = 0x760;
+ msg.msg_head.flags = 0;
+ msg.msg_head.nframes = 1;
+ msg.msg_head.count = 0;
+ msg.msg_head.ival1.tv_sec = 0;
+ msg.msg_head.ival1.tv_usec = 0;
+ msg.msg_head.ival2.tv_sec = 0;
+ msg.msg_head.ival2.tv_usec = 0;
+ msg.frame.can_id = 0x760;
+ msg.frame.can_dlc = 6;
+ msg.frame.data[0] = 0xA1;
+ msg.frame.data[1] = 0x0F;
+ msg.frame.data[2] = 0x10;
+ msg.frame.data[3] = 0x00;
+ msg.frame.data[4] = 0x00;
+ msg.frame.data[5] = 0x00;
- if (write(s, &msg, sizeof(msg)) < 0)
- perror("write");
+ if (write(s, &msg, sizeof(msg)) < 0)
+ perror("write");
- return 0;
+ return 0;
}