• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / JavaSpiNNaker / 6235384044

19 Sep 2023 12:12PM UTC coverage: 36.409% (-0.6%) from 36.982%
6235384044

Pull #658

github

dkfellows
More var
Pull Request #658: Update Java version to 17

1667 of 1667 new or added lines in 264 files covered. (100.0%)

8373 of 22997 relevant lines covered (36.41%)

0.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/messages/model/FirmwareDescriptor.java
1
/*
2
 * Copyright (c) 2022 The University of Manchester
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package uk.ac.manchester.spinnaker.messages.model;
17

18
import java.nio.ByteBuffer;
19
import java.nio.IntBuffer;
20
import java.time.Instant;
21

22
/**
23
 * A firmware descriptor.
24
 *
25
 * @param type
26
 *            What type of firmware is this.
27
 * @param descriptorData
28
 *            The descriptor buffer. Should be read-only.
29
 */
30
public record FirmwareDescriptor(FirmwareDescriptors type,
×
31
                IntBuffer descriptorData) {
32
        private static final int MAX_OLD_STYLE = 65535;
33

34
        private static final int OLD_SPLIT = 100;
35

36
        private static final int BYTE_MASK = 255;
37

38
        private static final int BYTE_SHIFT = 8;
39

40
        /**
41
         * Create a description of some firmware on a SpiNNaker system.
42
         *
43
         * @param type
44
         *            What type of firmware is this.
45
         * @param buffer
46
         *            What was the descriptor buffer read from the system?
47
         */
48
        public FirmwareDescriptor(FirmwareDescriptors type, ByteBuffer buffer) {
49
                this(type, buffer.asIntBuffer().asReadOnlyBuffer());
×
50
        }
×
51

52
        /** @return The version of the firmware. */
53
        public Version version() {
54
                int n = descriptorData.get(type.versionIndex);
×
55

56
                if (n <= MAX_OLD_STYLE) {
×
57
                        int major = n / OLD_SPLIT;
×
58
                        int minor = n % OLD_SPLIT;
×
59

60
                        return new Version(major, minor, 0);
×
61
                } else {
62
                        int major = n >> BYTE_SHIFT >> BYTE_SHIFT;
×
63
                        int minor = (n >> BYTE_SHIFT) & BYTE_MASK;
×
64
                        int rev = n & BYTE_MASK;
×
65

66
                        return new Version(major, minor, rev);
×
67
                }
68
        }
69

70
        /** @return The timestamp in the firmware. */
71
        public Instant timestamp() {
72
                return Instant.ofEpochSecond(descriptorData.get(type.timestampIndex));
×
73
        }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc