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

SpiNNakerManchester / JavaSpiNNaker / 6310285782

26 Sep 2023 08:47AM UTC coverage: 36.367% (-0.5%) from 36.866%
6310285782

Pull #658

github

dkfellows
Merge branch 'master' into java-17
Pull Request #658: Update Java version to 17 and JEE to 9

1675 of 1675 new or added lines in 266 files covered. (100.0%)

8368 of 23010 relevant lines covered (36.37%)

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/connections/IPAddressConnection.java
1
/*
2
 * Copyright (c) 2018 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.connections;
17

18
import static uk.ac.manchester.spinnaker.messages.Constants.UDP_BOOT_CONNECTION_DEFAULT_PORT;
19

20
import java.io.IOException;
21
import java.net.InetAddress;
22

23
/**
24
 * A connection that detects any UDP packet that is transmitted by SpiNNaker
25
 * boards prior to boot. Note that pre-boot messages contain no useful payload.
26
 */
27
public class IPAddressConnection extends UDPConnection<InetAddress> {
28
        /** Matches SPINN_PORT in spinnaker_bootROM. */
29
        private static final int BOOTROM_SPINN_PORT = 54321;
30

31
        /**
32
         * Create a connection listening on the default SpiNNaker pre-boot broadcast
33
         * port.
34
         *
35
         * @throws IOException
36
         *             If setting up the network fails.
37
         */
38
        public IPAddressConnection() throws IOException {
39
                this(null, UDP_BOOT_CONNECTION_DEFAULT_PORT);
×
40
        }
×
41

42
        /**
43
         * Create a connection listening on the default SpiNNaker pre-boot broadcast
44
         * port.
45
         *
46
         * @param localHost
47
         *            Local hostname to bind to.
48
         * @throws IOException
49
         *             If setting up the network fails.
50
         */
51
        public IPAddressConnection(InetAddress localHost) throws IOException {
52
                this(localHost, UDP_BOOT_CONNECTION_DEFAULT_PORT);
×
53
        }
×
54

55
        /**
56
         * Create a connection.
57
         *
58
         * @param localHost
59
         *            Local hostname to bind to.
60
         * @param localPort
61
         *            Local port to bind to.
62
         * @throws IOException
63
         *             If setting up the network fails.
64
         */
65
        public IPAddressConnection(InetAddress localHost, int localPort)
66
                        throws IOException {
67
                super(localHost, localPort, null, null, null);
×
68
        }
×
69

70
        /**
71
         * @return The IP address, or {@code null} if none was forthcoming.
72
         */
73
        @Override
74
        public final InetAddress receiveMessage() {
75
                return receiveMessage(Integer.MAX_VALUE);
×
76
        }
77

78
        /**
79
         * @param timeout
80
         *            How long to wait for an IP address; {@code null} for forever.
81
         * @return The IP address, or {@code null} if none was forthcoming.
82
         */
83
        @Override
84
        public InetAddress receiveMessage(int timeout) {
85
                try {
86
                        var packet = receiveWithAddress(timeout);
×
87
                        var addr = packet.address();
×
88
                        if (addr.getPort() == BOOTROM_SPINN_PORT) {
×
89
                                return addr.getAddress();
×
90
                        }
91
                } catch (IOException e) {
×
92
                        // Do nothing
93
                }
×
94
                return null;
×
95
        }
96
}
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

© 2026 Coveralls, Inc