Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Candidate: 2020-05-27 #101

Merged
merged 8 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Guide-GroundSystem.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cFS Ground System Version 2.1.10
# cFS Ground System Version 2.1.11

## cFS Ground System Info

Expand Down
2 changes: 1 addition & 1 deletion Guide-GroundSystem.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cFS Ground System Version 2.1.10
cFS Ground System Version 2.1.11

cFS Ground System Info:

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ See [Guide-GroundSystem.md](https://github.com/nasa/cFS-GroundSystem/blob/master

## Version History

### Development Build: 2.1.11

- Default behavior is the same except adds checksum and doesn't actually require fields. Adds all the packet fields, overrides, more supported data types, etc.
- See <https://github.com/nasa/cFS-GroundSystem/pull/101>

### Development Build: 2.1.10

- Change documentation for table loading guide to markdown
Expand Down
8 changes: 7 additions & 1 deletion Subsystems/cmdUtil/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
all::
all:
gcc -o cmdUtil SendUdp.c cmdUtil.c

debug:
gcc -o cmdUtil -DDEBUG -g SendUdp.c cmdUtil.c

thirtytwo:
gcc -o cmdUtil -DDEBUG -g -m32 SendUdp.c cmdUtil.c

111 changes: 59 additions & 52 deletions Subsystems/cmdUtil/SendUdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,99 +23,107 @@
#include "SendUdp.h"

#ifdef WIN32
#pragma warning (disable:4786)
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
typedef int socklen_t;
#pragma warning(disable : 4786)
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
typedef int socklen_t;
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SOCKET int
#define closesocket(fd) close(fd)
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define SOCKET int
#define closesocket(fd) close(fd)
#endif

/*
** SendUdp
*/
int SendUdp(char *hostname, char *portNum, char *packetData, int packetSize) {
SOCKET sd;
int rc;
int port;
int errcode;
unsigned int i;
struct sockaddr_in cliAddr;
struct addrinfo hints;
struct addrinfo *result;

#ifdef WIN32
WSADATA wsaData;
WSAStartup(WINSOCK_VERSION, &wsaData);
#endif

if (hostname == NULL) {
int SendUdp(char *hostname, char *portNum, unsigned char *packetData, int packetSize)
{
SOCKET sd;
int rc;
int port;
int errcode;
unsigned int i;
struct sockaddr_in cliAddr;
struct addrinfo hints;
struct addrinfo * result;

#ifdef WIN32
WSADATA wsaData;
WSAStartup(WINSOCK_VERSION, &wsaData);
#endif

if (hostname == NULL)
{
return -1;
}

/*
** Check port
*/
port = atoi(portNum);
if (port == -1) {
if (port == -1)
{
return -2;
}

/*
**Criteria for selecting socket address
**Criteria for selecting socket address
*/
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET; /*IPv4*/
hints.ai_family = AF_INET; /*IPv4*/
hints.ai_socktype = SOCK_DGRAM; /*Datagram socket*/
hints.ai_flags = AI_CANONNAME;
hints.ai_flags = AI_CANONNAME;
hints.ai_protocol = 0; /*Any Protocol*/

errcode = getaddrinfo(hostname, portNum, &hints, &result);
if (errcode != 0) {
if (errcode != 0)
{
return -3;
}

printf("sending data to '%s' (IP : %s); port %d\n", result->ai_canonname,
inet_ntoa(((struct sockaddr_in*)result->ai_addr)->sin_addr), port);
inet_ntoa(((struct sockaddr_in *)result->ai_addr)->sin_addr), port);

/*
** Create Socket
*/
sd = socket(AF_INET, SOCK_DGRAM, 0);

if(sd < 0){
if (sd < 0)
{
return -4;
}

/*
** bind any port
*/
cliAddr.sin_family = AF_INET;
cliAddr.sin_family = AF_INET;
cliAddr.sin_addr.s_addr = htonl(INADDR_ANY);
cliAddr.sin_port = htons(0);
cliAddr.sin_port = htons(0);

rc = bind(sd, (struct sockaddr *) &cliAddr, sizeof(cliAddr));
if (rc < 0) {
rc = bind(sd, (struct sockaddr *)&cliAddr, sizeof(cliAddr));
if (rc < 0)
{
printf("%s: cannot bind port\n", portNum);
return -5;
}

printf("Data to send:\n");
i = 0;
while (i < packetSize) {
while (i < packetSize)
{
printf("0x%02X ", packetData[i] & 0xFF);
if (++i % 8 == 0) {
if (++i % 8 == 0)
{
puts("");
}
}
Expand All @@ -124,11 +132,10 @@ int SendUdp(char *hostname, char *portNum, char *packetData, int packetSize) {
/*
** send the event
*/
rc = sendto(sd, (char*)packetData, packetSize, 0,
result->ai_addr, result->ai_addrlen);

rc = sendto(sd, (char *)packetData, packetSize, 0, result->ai_addr, result->ai_addrlen);

if (rc < 0) {
if (rc < 0)
{
freeaddrinfo(result);
closesocket(sd);
return -6;
Expand Down
6 changes: 5 additions & 1 deletion Subsystems/cmdUtil/SendUdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*/
int SendUdp(char *hostname, char *portNum, char *packetData, int packetSize);
#ifndef _sendudp_
#define _sendudp_

int SendUdp(char *hostname, char *portNum, unsigned char *packetData, int packetSize);

#endif /* _sendudp_ */
Loading