Skip to content

Commit 0748be4

Browse files
authored
Merge pull request #25 from ichiro-its/miscellaneous-changes
Miscellaneous changes
2 parents 84b5331 + 3200f37 commit 0748be4

16 files changed

+213
-54
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
name: Build and Test
22
on:
3+
workflow_dispatch:
34
pull_request:
4-
branches: [ master ]
5+
branches: [master]
56
push:
6-
branches: [ master ]
7+
branches: [master]
78
jobs:
89
build-and-test:
910
runs-on: ubuntu-latest
1011
steps:
11-
- name: Checking out
12+
- name: Checkout this repository
1213
uses: actions/checkout@v2.3.4
13-
- name: Building and testing
14-
uses: ichiro-its/ros2-ci@v1.0.0
1514
with:
16-
ros2-distro: foxy
15+
path: musen
16+
17+
- name: Build and test workspace
18+
uses: ichiro-its/ros2-build-and-test-action@main
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy Debian Nightly
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [master]
6+
jobs:
7+
deploy-debian-nightly:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout this repository
11+
uses: actions/checkout@v2.3.4
12+
with:
13+
path: musen
14+
15+
- name: Build nightly Debian package
16+
uses: ichiro-its/ros2-build-debian-action@main
17+
with:
18+
unique-version: true
19+
20+
- name: Deploy nightly Debian package to server
21+
uses: appleboy/scp-action@master
22+
with:
23+
host: ${{ secrets.SSH_HOST }}
24+
port: ${{ secrets.SSH_PORT }}
25+
username: ${{ secrets.SSH_USER }}
26+
password: ${{ secrets.SSH_PASS }}
27+
source: "package/*.deb"
28+
target: "~/temp/nightly/musen/"
29+
rm: true
30+
31+
- name: Prepare nightly Debian package in the server
32+
uses: appleboy/ssh-action@master
33+
with:
34+
host: ${{ secrets.SSH_HOST }}
35+
port: ${{ secrets.SSH_PORT }}
36+
username: ${{ secrets.SSH_USER }}
37+
password: ${{ secrets.SSH_PASS }}
38+
script: |
39+
cd ~/repository/debian
40+
reprepro includedeb nightly ~/temp/nightly/musen/package/*.deb
41+
rm -rf ~/temp/nightly/musen/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy Debian Stable
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [created]
6+
jobs:
7+
deploy-debian-stable:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout this repository
11+
uses: actions/checkout@v2.3.4
12+
with:
13+
path: musen
14+
15+
- name: Build stable Debian package
16+
uses: ichiro-its/ros2-build-debian-action@main
17+
18+
- name: Deploy stable Debian package to server
19+
uses: appleboy/scp-action@master
20+
with:
21+
host: ${{ secrets.SSH_HOST }}
22+
port: ${{ secrets.SSH_PORT }}
23+
username: ${{ secrets.SSH_USER }}
24+
password: ${{ secrets.SSH_PASS }}
25+
source: "package/*.deb"
26+
target: "~/temp/stable/musen/"
27+
rm: true
28+
29+
- name: Prepare stable Debian package in the server
30+
uses: appleboy/ssh-action@master
31+
with:
32+
host: ${{ secrets.SSH_HOST }}
33+
port: ${{ secrets.SSH_PORT }}
34+
username: ${{ secrets.SSH_USER }}
35+
password: ${{ secrets.SSH_PASS }}
36+
script: |
37+
cd ~/repository/debian
38+
reprepro includedeb stable ~/temp/stable/musen/package/*.deb
39+
rm -rf ~/temp/stable/musen/

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
[![latest version](https://img.shields.io/github/v/release/ichiro-its/musen)](https://github.com/ichiro-its/musen/releases/)
44
[![commits since latest version](https://img.shields.io/github/commits-since/ichiro-its/musen/latest)](https://github.com/ichiro-its/musen/commits/master)
5-
[![milestone](https://img.shields.io/github/milestones/progress/ichiro-its/musen/1?label=milestone)](https://github.com/ichiro-its/musen/milestone/2)
65
[![license](https://img.shields.io/github/license/ichiro-its/musen)](./LICENSE)
7-
[![build and test status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Build%20and%20Test?label=build%20and%20test)](https://github.com/ichiro-its/musen/actions)
6+
[![test status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Build%20and%20Test?label=test)](https://github.com/ichiro-its/musen/actions)
7+
[![deploy stable status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Deploy%20Debian%20Stable?label=deploy%20stable)](https://repository.ichiro-its.org/)
8+
[![deploy nightly status](https://img.shields.io/github/workflow/status/ichiro-its/musen/Deploy%20Debian%20Nightly?label=deploy%20nightly)](https://repository.ichiro-its.org/)
89

910
Musen (無線, wireless) is a [ROS 2](https://docs.ros.org/en/foxy/index.html) package that provides a [UDP](https://en.wikipedia.org/wiki/User_Datagram_Protocol) broadcast communication library for a ROS 2 project.
1011
This package is written in C++ and currently only works on Linux based operating system.
@@ -25,7 +26,7 @@ In this package, the broadcast communication will be handled by a Broadcaster ob
2526
### Binary Packages
2627

2728
- See [releases](https://github.com/ichiro-its/musen/releases) for the latest version of this package.
28-
- Alternatively, this package is available on [ICHIRO ITS Repository](https://repository.ichiro-its.org/) as a `ros-foxy-musen` package.
29+
- Alternatively, this package also available on [ICHIRO ITS Repository](https://repository.ichiro-its.org/) as `ros-foxy-musen` package.
2930

3031
### Build From Source
3132

include/musen/broadcaster/base_broadcaster.hpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,46 @@
2323

2424
#include <arpa/inet.h>
2525

26-
#include <string>
2726
#include <list>
27+
#include <memory>
28+
#include <string>
2829

2930
#include "../udp_socket.hpp"
3031

3132
namespace musen
3233
{
3334

34-
class BaseBroadcaster : public UdpSocket
35+
class BaseBroadcaster
3536
{
3637
public:
37-
explicit BaseBroadcaster(const int & port);
38+
explicit BaseBroadcaster(
39+
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());
40+
41+
bool connect();
42+
bool disconnect();
3843

39-
int send(const void * data, const int & length);
44+
int send(const char * data, const int & length);
4045

4146
void enable_broadcast(const bool & enable);
4247
void add_target_host(const std::string & host);
4348

49+
std::shared_ptr<UdpSocket> get_udp_socket() const;
50+
4451
const int & get_port() const;
4552

4653
protected:
47-
std::list<struct sockaddr_in> get_recipent_sas() const;
48-
std::list<struct sockaddr_in> get_recipent_sas_from_broadcast_ifas() const;
49-
std::list<struct sockaddr_in> get_recipent_sas_from_target_hosts() const;
54+
std::list<struct sockaddr_in> obtain_recipent_sas() const;
55+
std::list<struct sockaddr_in> obtain_recipent_sas_from_broadcast_ifas() const;
56+
std::list<struct sockaddr_in> obtain_recipent_sas_from_target_hosts() const;
57+
58+
std::shared_ptr<UdpSocket> udp_socket;
5059

5160
bool broadcast;
5261
std::list<std::string> target_hosts;
5362

5463
int port;
64+
65+
std::list<struct sockaddr_in> recipent_sas;
5566
};
5667

5768
} // namespace musen

include/musen/broadcaster/broadcaster.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#ifndef MUSEN__BROADCASTER__BROADCASTER_HPP_
2222
#define MUSEN__BROADCASTER__BROADCASTER_HPP_
2323

24+
#include <memory>
25+
2426
#include "./base_broadcaster.hpp"
2527

2628
namespace musen
@@ -30,14 +32,15 @@ template<typename T>
3032
class Broadcaster : public BaseBroadcaster
3133
{
3234
public:
33-
explicit Broadcaster(const int & port)
34-
: BaseBroadcaster(port)
35+
explicit Broadcaster(
36+
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>())
37+
: BaseBroadcaster(port, udp_socket)
3538
{
3639
}
3740

3841
int send(const T & data)
3942
{
40-
return BaseBroadcaster::send(&data, sizeof(data));
43+
return BaseBroadcaster::send((const char *)&data, sizeof(data));
4144
}
4245
};
4346

include/musen/broadcaster/string_broadcaster.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#ifndef MUSEN__BROADCASTER__STRING_BROADCASTER_HPP_
2222
#define MUSEN__BROADCASTER__STRING_BROADCASTER_HPP_
2323

24+
#include <memory>
2425
#include <string>
2526
#include <vector>
2627

@@ -32,7 +33,8 @@ namespace musen
3233
class StringBroadcaster : public BaseBroadcaster
3334
{
3435
public:
35-
explicit StringBroadcaster(const int & port);
36+
explicit StringBroadcaster(
37+
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());
3638

3739
int send(const std::string & message);
3840
int send(const std::vector<std::string> & messages, const std::string & delimiter = ",");

include/musen/listener/base_listener.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#ifndef MUSEN__LISTENER__BASE_LISTENER_HPP_
2222
#define MUSEN__LISTENER__BASE_LISTENER_HPP_
2323

24+
#include <memory>
25+
2426
#include "../udp_socket.hpp"
2527

2628
namespace musen
@@ -29,15 +31,21 @@ namespace musen
2931
class BaseListener : public UdpSocket
3032
{
3133
public:
32-
explicit BaseListener(const int & port);
34+
explicit BaseListener(
35+
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());
3336

34-
bool connect() override;
37+
bool connect();
38+
bool disconnect();
3539

3640
int receive(void * buffer, const int & length);
3741

42+
std::shared_ptr<UdpSocket> get_udp_socket() const;
43+
3844
const int & get_port() const;
3945

4046
protected:
47+
std::shared_ptr<UdpSocket> udp_socket;
48+
4149
int port;
4250
};
4351

include/musen/listener/listener.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ template<typename T>
3232
class Listener : public BaseListener
3333
{
3434
public:
35-
explicit Listener(const int & port)
36-
: BaseListener(port)
35+
explicit Listener(
36+
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>())
37+
: BaseListener(port, udp_socket)
3738
{
3839
}
3940

include/musen/listener/string_listener.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#ifndef MUSEN__LISTENER__STRING_LISTENER_HPP_
2222
#define MUSEN__LISTENER__STRING_LISTENER_HPP_
2323

24+
#include <memory>
2425
#include <string>
2526
#include <vector>
2627

@@ -32,7 +33,8 @@ namespace musen
3233
class StringListener : public BaseListener
3334
{
3435
public:
35-
explicit StringListener(const int & port);
36+
explicit StringListener(
37+
const int & port, std::shared_ptr<UdpSocket> udp_socket = std::make_shared<UdpSocket>());
3638

3739
std::string receive(const int & length);
3840
std::vector<std::string> receive(const int & length, const std::string & delimiter);

0 commit comments

Comments
 (0)