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

github: update to use git repo of master #49

Merged
merged 2 commits into from
Aug 10, 2024
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
42 changes: 22 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Build
name: CI

on:
push:
branches:
- master
branches: [master]
pull_request:

env:
Expand All @@ -13,34 +12,37 @@ jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt
- name: Check rust formatting (rustfmt)
run: cargo fmt --all -- --check
- run: cargo fmt --all -- --check

build:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- 1.63.0
- stable
- nightly
env:
ETHERCAT_PATH: ../ethercat-git
steps:
- uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
profile: minimal
toolchain: ${{ matrix.toolchain }}
components: clippy

- name: Install Mercurial
run: sudo apt-get install -y mercurial
- name: Set up IgH repo
run: |
hg clone http://hg.code.sf.net/p/etherlabmaster/code ethercat-hg
cd ethercat-hg
hg update stable-1.5
git clone https://gitlab.com/etherlab.org/ethercat ethercat-git
cd ethercat-git
git checkout stable-1.5
./bootstrap
./configure --disable-8139too

- name: Build
run: ETHERCAT_PATH=$(pwd)/ethercat-hg cargo build
- run: cargo clippy --all-targets
- run: cargo build --all-targets
2 changes: 2 additions & 0 deletions ethercat-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ioctl-sys = "0.5.2"
[build-dependencies]
bindgen = "0.63.0"
regex = "=1.9.6"
# for 1.63 compatibility
home = "=0.5.5"

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion ethercat-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() {
.expect("Couldn't write bindings!");

// Generate the EC_IOCTL_ ioctl numbers -- bindgen can't handle them.
let code = fs::read_to_string(&format!("{}/master/ioctl.h", path))
let code = fs::read_to_string(format!("{}/master/ioctl.h", path))
.expect("master/ioctl.h not found");
let mut new = String::new();
for line in code.split('\n') {
Expand Down
15 changes: 5 additions & 10 deletions examples/cyclic-data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,12 @@ pub fn main() -> Result<(), io::Error> {
}
}

type SlaveMap = HashMap<SlavePos, HashMap<PdoEntryIndex, (BitLen, Offset)>>;

pub fn init_master(
esi: &EtherCatInfo,
idx: u32,
) -> Result<
(
Master,
DomainIndex,
HashMap<SlavePos, HashMap<PdoEntryIndex, (BitLen, Offset)>>,
),
io::Error,
> {
) -> Result<(Master, DomainIndex, SlaveMap), io::Error> {
let mut master = Master::open(idx, MasterAccess::ReadWrite)?;
log::debug!("Reserve master");
master.reserve()?;
Expand Down Expand Up @@ -111,7 +106,7 @@ pub fn init_master(
sub_idx: SubIdx::from(e.sub_index.unwrap_or(1) as u8),
},
bit_len: e.bit_len as u8,
name: e.name.clone().unwrap_or(String::new()),
name: e.name.clone().unwrap_or_default(),
pos: PdoEntryPos::from(i as u8),
})
.collect(),
Expand All @@ -133,7 +128,7 @@ pub fn init_master(
sub_idx: SubIdx::from(e.sub_index.unwrap_or(1) as u8),
},
bit_len: e.bit_len as u8,
name: e.name.clone().unwrap_or(String::new()),
name: e.name.clone().unwrap_or_default(),
pos: PdoEntryPos::from(i as u8),
})
.collect(),
Expand Down
6 changes: 3 additions & 3 deletions src/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Master {
let p = self
.domain_data_placement(idx)
.map_err(|_| Error::NoDomain)?;
let data = self.map.as_mut().ok_or_else(|| Error::NotActivated)?;
let data = self.map.as_mut().ok_or(Error::NotActivated)?;
Ok(&mut data[p.offset..p.offset + p.size])
}

Expand Down Expand Up @@ -119,7 +119,7 @@ impl Master {
.map_mut(&self.file)
.map(Some)?
};
self.map.as_mut().ok_or_else(|| Error::NotActivated)?[0] = 0;
self.map.as_mut().ok_or(Error::NotActivated)?[0] = 0;
Ok(())
}

Expand Down Expand Up @@ -183,7 +183,7 @@ impl Master {
app_time,
..
} = data;
let first_device = devices.get(0).ok_or_else(|| Error::NoDevices)?;
let first_device = devices.first().ok_or(Error::NoDevices)?;
let link_up = first_device.link_state != 0;
let scan_busy = scan_busy != 0;
Ok(MasterInfo {
Expand Down